浏览代码

`header_template` source kind is a header file with a `.config` on its stem

default_compile_flags
vector-of-bool 5 年前
父节点
当前提交
8311ad7c28
共有 3 个文件被更改,包括 23 次插入2 次删除
  1. +6
    -2
      src/dds/source/file.cpp
  2. +1
    -0
      src/dds/source/file.hpp
  3. +16
    -0
      src/dds/source/file.test.cpp

+ 6
- 2
src/dds/source/file.cpp 查看文件

auto ext_found auto ext_found
= std::lower_bound(header_exts.begin(), header_exts.end(), p.extension(), std::less<>()); = std::lower_bound(header_exts.begin(), header_exts.end(), p.extension(), std::less<>());
if (ext_found != header_exts.end() && *ext_found == p.extension()) { if (ext_found != header_exts.end() && *ext_found == p.extension()) {
auto stem = p.stem();
if (stem.extension() == ".config") {
return source_kind::header_template;
}
return source_kind::header; return source_kind::header;
} }


return std::nullopt; return std::nullopt;
} }


if (ends_with(p.stem().string(), ".test")) {
if (p.stem().extension() == ".test") {
return source_kind::test; return source_kind::test;
} }


if (ends_with(p.stem().string(), ".main")) {
if (p.stem().extension() == ".main") {
return source_kind::app; return source_kind::app;
} }



+ 1
- 0
src/dds/source/file.hpp 查看文件



enum class source_kind { enum class source_kind {
header, header,
header_template,
source, source,
test, test,
app, app,

+ 16
- 0
src/dds/source/file.test.cpp 查看文件

#include <dds/source/file.hpp>

#include <catch2/catch.hpp>

using dds::source_kind;

TEST_CASE("Infer source kind") {
using dds::infer_source_kind;
auto k = infer_source_kind("foo.h");
CHECK(k == source_kind::header);
CHECK(infer_source_kind("foo.hpp") == source_kind::header);
CHECK_FALSE(infer_source_kind("foo.txt")); // Not a source file extension

CHECK(infer_source_kind("foo.hh") == source_kind::header);
CHECK(infer_source_kind("foo.config.hpp") == source_kind::header_template);
}

正在加载...
取消
保存