From 1484d74c1dfd24cfe5b6f13f76d58ff395e4d253 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Tue, 10 Jan 2023 16:00:36 +0100 Subject: Put ctor.h contents in ctor namespace. --- test/ctor.cc | 12 ++++++------ test/source_type_test.cc | 31 +++++++++++++++++-------------- test/tasks_test.cc | 2 ++ test/tools_test.cc | 4 ++++ 4 files changed, 29 insertions(+), 20 deletions(-) (limited to 'test') diff --git a/test/ctor.cc b/test/ctor.cc index 89a94b9..1a63486 100644 --- a/test/ctor.cc +++ b/test/ctor.cc @@ -5,12 +5,12 @@ namespace { -BuildConfigurations ctorTestConfigs(const Settings& settings) +ctor::BuildConfigurations ctorTestConfigs(const ctor::Settings& settings) { return { { - .type = TargetType::UnitTest, + .type = ctor::TargetType::UnitTest, .target = "execute_test", .sources = { "execute_test.cc", @@ -27,7 +27,7 @@ BuildConfigurations ctorTestConfigs(const Settings& settings) }, }, { - .type = TargetType::UnitTest, + .type = ctor::TargetType::UnitTest, .target = "tasks_test", .sources = { "tasks_test.cc", @@ -44,7 +44,7 @@ BuildConfigurations ctorTestConfigs(const Settings& settings) }, }, { - .type = TargetType::UnitTest, + .type = ctor::TargetType::UnitTest, .target = "source_type_test", .sources = { "source_type_test.cc", @@ -61,7 +61,7 @@ BuildConfigurations ctorTestConfigs(const Settings& settings) }, }, { - .type = TargetType::UnitTest, + .type = ctor::TargetType::UnitTest, .target = "tools_test", .sources = { "tools_test.cc", @@ -78,7 +78,7 @@ BuildConfigurations ctorTestConfigs(const Settings& settings) }, }, { - .type = TargetType::UnitTestLib, + .type = ctor::TargetType::UnitTestLib, .target = "libctor_nomain.a", .sources = { "../src/build.cc", diff --git a/test/source_type_test.cc b/test/source_type_test.cc index ce1923e..e64aaee 100644 --- a/test/source_type_test.cc +++ b/test/source_type_test.cc @@ -1,37 +1,40 @@ -#include - #include #include -std::ostream& operator<<(std::ostream& stream, const Language& lang) +std::ostream& operator<<(std::ostream& stream, const ctor::Language& lang); + +#include + +std::ostream& operator<<(std::ostream& stream, const ctor::Language& lang) { switch(lang) { - case Language::Auto: + case ctor::Language::Auto: stream << "Language::Auto"; break; - case Language::C: + case ctor::Language::C: stream << "Language::C"; break; - case Language::Cpp: + case ctor::Language::Cpp: stream << "Language::Cpp"; break; - case Language::Asm: + case ctor::Language::Asm: stream << "Language::Asm"; break; } return stream; } + class TestableTaskCC : public TaskCC { public: - TestableTaskCC(const Source& source) + TestableTaskCC(const ctor::Source& source) : TaskCC({}, {}, "build", source) {} - Language language() const + ctor::Language language() const { return source_language; } @@ -50,22 +53,22 @@ public: { { // c++ TestableTaskCC task("hello.cc"); - uASSERT_EQUAL(Language::Cpp, task.language()); + uASSERT_EQUAL(ctor::Language::Cpp, task.language()); } { // c TestableTaskCC task("hello.c"); - uASSERT_EQUAL(Language::C, task.language()); + uASSERT_EQUAL(ctor::Language::C, task.language()); } { // asm TestableTaskCC task("hello.s"); - uASSERT_EQUAL(Language::Asm, task.language()); + uASSERT_EQUAL(ctor::Language::Asm, task.language()); } { // custom/explicit language - TestableTaskCC task( {"hello.foo", Language::Asm} ); - uASSERT_EQUAL(Language::Asm, task.language()); + TestableTaskCC task( {"hello.foo", ctor::Language::Asm} ); + uASSERT_EQUAL(ctor::Language::Asm, task.language()); } // Note: Failure state will result in exit(1) so cannot be tested diff --git a/test/tasks_test.cc b/test/tasks_test.cc index a660994..594261d 100644 --- a/test/tasks_test.cc +++ b/test/tasks_test.cc @@ -3,6 +3,8 @@ #include #include +using namespace ctor; + namespace { BuildConfigurations ctorTestConfigs1(const Settings&) diff --git a/test/tools_test.cc b/test/tools_test.cc index 743edb6..0f97bd3 100644 --- a/test/tools_test.cc +++ b/test/tools_test.cc @@ -11,6 +11,7 @@ std::ostream& operator<<(std::ostream& stream, const std::vector& v #include +using namespace ctor; using namespace std::string_literals; std::ostream& operator<<(std::ostream& stream, const ToolChain& tool_chain) @@ -85,6 +86,8 @@ namespace std::string conf_host_cxx{}; std::string conf_build_cxx{}; } + +namespace ctor { const std::string& getConfiguration(const std::string& key, const std::string& defval) { @@ -103,6 +106,7 @@ const std::string& getConfiguration(const std::string& key, static std::string res{}; return res; } +} // namespace ctor:: class ToolsTest : public uUnit -- cgit v1.2.3