diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/tools_test.cc | 128 |
1 files changed, 65 insertions, 63 deletions
diff --git a/test/tools_test.cc b/test/tools_test.cc index 4cc9a77..118490f 100644 --- a/test/tools_test.cc +++ b/test/tools_test.cc @@ -5,7 +5,9 @@ #include <tools.h> std::ostream& operator<<(std::ostream& stream, const std::vector<std::string>& vs); -std::ostream& operator<<(std::ostream& stream, const ctor::toolchain& tool_chain); +std::ostream& operator<<(std::ostream& stream, const ctor::toolchain& toolchain); +std::ostream& operator<<(std::ostream& stream, const ctor::opt& opt); +std::ostream& operator<<(std::ostream& stream, const std::pair<ctor::opt, std::string>& vs); #include <uunit.h> @@ -14,9 +16,9 @@ std::ostream& operator<<(std::ostream& stream, const ctor::toolchain& tool_chain using namespace std::string_literals; -std::ostream& operator<<(std::ostream& stream, const ctor::toolchain& tool_chain) +std::ostream& operator<<(std::ostream& stream, const ctor::toolchain& toolchain) { - switch(tool_chain) + switch(toolchain) { case ctor::toolchain::none: stream << "ctor::toolchain::none"; @@ -52,34 +54,34 @@ std::ostream& operator<<(std::ostream& stream, const std::vector<std::string>& v return stream; } -std::ostream& operator<<(std::ostream& stream, opt o) +std::ostream& operator<<(std::ostream& stream, const ctor::opt& opt) { // Adding to this enum should also imply adding to the unit-tests below - switch(o) + switch(opt) { - case opt::output: stream << "opt::output"; break; - case opt::debug: stream << "opt::debug"; break; - case opt::strip: stream << "opt::strip"; break; - case opt::warn_all: stream << "opt::warn_all"; break; - case opt::warnings_as_errors: stream << "opt::warnings_as_errors"; break; - case opt::generate_dep_tree: stream << "opt::generate_dep_tree"; break; - case opt::no_link: stream << "opt::no_link"; break; - case opt::include_path: stream << "opt::include_path"; break; - case opt::library_path: stream << "opt::library_path"; break; - case opt::link: stream << "opt::link"; break; - case opt::cpp_std: stream << "opt::cpp_std"; break; - case opt::build_shared: stream << "opt::build_shared"; break; - case opt::threads: stream << "opt::threads"; break; - case opt::optimization: stream << "opt::optimization"; break; - case opt::position_independent_code: stream << "opt::position_independent_code"; break; - case opt::position_independent_executable: stream << "opt::position_independent_executable"; break; - case opt::custom: stream << "opt::custom"; break; + case ctor::opt::output: stream << "ctor::opt::output"; break; + case ctor::opt::debug: stream << "ctor::opt::debug"; break; + case ctor::opt::strip: stream << "ctor::opt::strip"; break; + case ctor::opt::warn_all: stream << "ctor::opt::warn_all"; break; + case ctor::opt::warnings_as_errors: stream << "ctor::opt::warnings_as_errors"; break; + case ctor::opt::generate_dep_tree: stream << "ctor::opt::generate_dep_tree"; break; + case ctor::opt::no_link: stream << "ctor::opt::no_link"; break; + case ctor::opt::include_path: stream << "ctor::opt::include_path"; break; + case ctor::opt::library_path: stream << "ctor::opt::library_path"; break; + case ctor::opt::link: stream << "ctor::opt::link"; break; + case ctor::opt::cpp_std: stream << "ctor::opt::cpp_std"; break; + case ctor::opt::build_shared: stream << "ctor::opt::build_shared"; break; + case ctor::opt::threads: stream << "ctor::opt::threads"; break; + case ctor::opt::optimization: stream << "ctor::opt::optimization"; break; + case ctor::opt::position_independent_code: stream << "ctor::opt::position_independent_code"; break; + case ctor::opt::position_independent_executable: stream << "ctor::opt::position_independent_executable"; break; + case ctor::opt::custom: stream << "ctor::opt::custom"; break; } return stream; } -std::ostream& operator<<(std::ostream& stream, const std::pair<opt, std::string>& vs) +std::ostream& operator<<(std::ostream& stream, const std::pair<ctor::opt, std::string>& vs) { stream << "{ " << vs.first << ", " << vs.second << " }"; @@ -142,160 +144,160 @@ public: std::vector<std::string> act; exp = { "-o", "foo" }; - act = getOption(ctor::toolchain::clang, opt::output, "foo"); + act = getOption(ctor::toolchain::clang, ctor::opt::output, "foo"); uASSERT_EQUAL(exp, act); exp = { "-g" }; - act = getOption(ctor::toolchain::clang, opt::debug); + act = getOption(ctor::toolchain::clang, ctor::opt::debug); uASSERT_EQUAL(exp, act); exp = { "-s" }; - act = getOption(ctor::toolchain::clang, opt::strip); + act = getOption(ctor::toolchain::clang, ctor::opt::strip); uASSERT_EQUAL(exp, act); exp = { "-Wall" }; - act = getOption(ctor::toolchain::clang, opt::warn_all); + act = getOption(ctor::toolchain::clang, ctor::opt::warn_all); uASSERT_EQUAL(exp, act); exp = { "-Werror" }; - act = getOption(ctor::toolchain::clang, opt::warnings_as_errors); + act = getOption(ctor::toolchain::clang, ctor::opt::warnings_as_errors); uASSERT_EQUAL(exp, act); exp = { "-MMD" }; - act = getOption(ctor::toolchain::clang, opt::generate_dep_tree); + act = getOption(ctor::toolchain::clang, ctor::opt::generate_dep_tree); uASSERT_EQUAL(exp, act); exp = { "-c" }; - act = getOption(ctor::toolchain::clang, opt::no_link); + act = getOption(ctor::toolchain::clang, ctor::opt::no_link); uASSERT_EQUAL(exp, act); exp = { "-Ifoo" }; - act = getOption(ctor::toolchain::clang, opt::include_path, "foo"); + act = getOption(ctor::toolchain::clang, ctor::opt::include_path, "foo"); uASSERT_EQUAL(exp, act); exp = { "-Lfoo" }; - act = getOption(ctor::toolchain::clang, opt::library_path, "foo"); + act = getOption(ctor::toolchain::clang, ctor::opt::library_path, "foo"); uASSERT_EQUAL(exp, act); exp = { "-lfoo" }; - act = getOption(ctor::toolchain::clang, opt::link, "foo"); + act = getOption(ctor::toolchain::clang, ctor::opt::link, "foo"); uASSERT_EQUAL(exp, act); exp = { "-std=foo" }; - act = getOption(ctor::toolchain::clang, opt::cpp_std, "foo"); + act = getOption(ctor::toolchain::clang, ctor::opt::cpp_std, "foo"); uASSERT_EQUAL(exp, act); exp = { "-shared" }; - act = getOption(ctor::toolchain::clang, opt::build_shared); + act = getOption(ctor::toolchain::clang, ctor::opt::build_shared); uASSERT_EQUAL(exp, act); exp = { "-pthread" }; - act = getOption(ctor::toolchain::clang, opt::threads); + act = getOption(ctor::toolchain::clang, ctor::opt::threads); uASSERT_EQUAL(exp, act); exp = { "-Ofoo" }; - act = getOption(ctor::toolchain::clang, opt::optimization, "foo"); + act = getOption(ctor::toolchain::clang, ctor::opt::optimization, "foo"); uASSERT_EQUAL(exp, act); exp = { "-fPIC" }; - act = getOption(ctor::toolchain::clang, opt::position_independent_code); + act = getOption(ctor::toolchain::clang, ctor::opt::position_independent_code); uASSERT_EQUAL(exp, act); exp = { "-fPIE" }; - act = getOption(ctor::toolchain::clang, opt::position_independent_executable); + act = getOption(ctor::toolchain::clang, ctor::opt::position_independent_executable); uASSERT_EQUAL(exp, act); exp = { "-foo" }; - act = getOption(ctor::toolchain::clang, opt::custom, "-foo"); + act = getOption(ctor::toolchain::clang, ctor::opt::custom, "-foo"); uASSERT_EQUAL(exp, act); exp = { "-o", "foo" }; - act = getOption(ctor::toolchain::gcc, opt::output, "foo"); + act = getOption(ctor::toolchain::gcc, ctor::opt::output, "foo"); uASSERT_EQUAL(exp, act); exp = { "-g" }; - act = getOption(ctor::toolchain::gcc, opt::debug); + act = getOption(ctor::toolchain::gcc, ctor::opt::debug); uASSERT_EQUAL(exp, act); exp = { "-s" }; - act = getOption(ctor::toolchain::gcc, opt::strip); + act = getOption(ctor::toolchain::gcc, ctor::opt::strip); uASSERT_EQUAL(exp, act); exp = { "-Wall" }; - act = getOption(ctor::toolchain::gcc, opt::warn_all); + act = getOption(ctor::toolchain::gcc, ctor::opt::warn_all); uASSERT_EQUAL(exp, act); exp = { "-Werror" }; - act = getOption(ctor::toolchain::gcc, opt::warnings_as_errors); + act = getOption(ctor::toolchain::gcc, ctor::opt::warnings_as_errors); uASSERT_EQUAL(exp, act); exp = { "-MMD" }; - act = getOption(ctor::toolchain::gcc, opt::generate_dep_tree); + act = getOption(ctor::toolchain::gcc, ctor::opt::generate_dep_tree); uASSERT_EQUAL(exp, act); exp = { "-c" }; - act = getOption(ctor::toolchain::gcc, opt::no_link); + act = getOption(ctor::toolchain::gcc, ctor::opt::no_link); uASSERT_EQUAL(exp, act); exp = { "-Ifoo" }; - act = getOption(ctor::toolchain::gcc, opt::include_path, "foo"); + act = getOption(ctor::toolchain::gcc, ctor::opt::include_path, "foo"); uASSERT_EQUAL(exp, act); exp = { "-Lfoo" }; - act = getOption(ctor::toolchain::gcc, opt::library_path, "foo"); + act = getOption(ctor::toolchain::gcc, ctor::opt::library_path, "foo"); uASSERT_EQUAL(exp, act); exp = { "-lfoo" }; - act = getOption(ctor::toolchain::gcc, opt::link, "foo"); + act = getOption(ctor::toolchain::gcc, ctor::opt::link, "foo"); uASSERT_EQUAL(exp, act); exp = { "-std=foo" }; - act = getOption(ctor::toolchain::gcc, opt::cpp_std, "foo"); + act = getOption(ctor::toolchain::gcc, ctor::opt::cpp_std, "foo"); uASSERT_EQUAL(exp, act); exp = { "-shared" }; - act = getOption(ctor::toolchain::gcc, opt::build_shared); + act = getOption(ctor::toolchain::gcc, ctor::opt::build_shared); uASSERT_EQUAL(exp, act); exp = { "-pthread" }; - act = getOption(ctor::toolchain::gcc, opt::threads); + act = getOption(ctor::toolchain::gcc, ctor::opt::threads); uASSERT_EQUAL(exp, act); exp = { "-Ofoo" }; - act = getOption(ctor::toolchain::gcc, opt::optimization, "foo"); + act = getOption(ctor::toolchain::gcc, ctor::opt::optimization, "foo"); uASSERT_EQUAL(exp, act); exp = { "-fPIC" }; - act = getOption(ctor::toolchain::gcc, opt::position_independent_code); + act = getOption(ctor::toolchain::gcc, ctor::opt::position_independent_code); uASSERT_EQUAL(exp, act); exp = { "-fPIE" }; - act = getOption(ctor::toolchain::gcc, opt::position_independent_executable); + act = getOption(ctor::toolchain::gcc, ctor::opt::position_independent_executable); uASSERT_EQUAL(exp, act); exp = { "-foo" }; - act = getOption(ctor::toolchain::gcc, opt::custom, "-foo"); + act = getOption(ctor::toolchain::gcc, ctor::opt::custom, "-foo"); uASSERT_EQUAL(exp, act); } void getOption_str_test() { - std::pair<opt, std::string> exp; - std::pair<opt, std::string> act; + std::pair<ctor::opt, std::string> exp; + std::pair<ctor::opt, std::string> act; - exp = { opt::include_path, "foo" }; + exp = { ctor::opt::include_path, "foo" }; act = getOption("-Ifoo", ctor::toolchain::gcc); uASSERT_EQUAL(exp, act); - exp = { opt::library_path, "foo" }; + exp = { ctor::opt::library_path, "foo" }; act = getOption("-Lfoo", ctor::toolchain::gcc); uASSERT_EQUAL(exp, act); - exp = { opt::include_path, "foo" }; + exp = { ctor::opt::include_path, "foo" }; act = getOption("-Ifoo", ctor::toolchain::clang); uASSERT_EQUAL(exp, act); - exp = { opt::library_path, "foo" }; + exp = { ctor::opt::library_path, "foo" }; act = getOption("-Lfoo", ctor::toolchain::clang); uASSERT_EQUAL(exp, act); } |