diff options
author | 2011-03-21 13:21:40 +0000 | |
---|---|---|
committer | 2011-03-21 13:21:40 +0000 | |
commit | 8caf9128e15a16826d1521a13b08fb763e8e5378 (patch) | |
tree | f782cb0d493cbae253a1a9376811d98870dd83be | |
parent | f9037864e60f831804503a9a3457ce64d6c54ce7 (diff) | |
download | paludis-8caf9128e15a16826d1521a13b08fb763e8e5378.tar.gz paludis-8caf9128e15a16826d1521a13b08fb763e8e5378.tar.xz |
gtest more
-rw-r--r-- | paludis/elike_dep_parser_TEST.cc | 215 | ||||
-rw-r--r-- | paludis/files.m4 | 2 |
2 files changed, 97 insertions, 120 deletions
diff --git a/paludis/elike_dep_parser_TEST.cc b/paludis/elike_dep_parser_TEST.cc index e517a73b3..299377ca4 100644 --- a/paludis/elike_dep_parser_TEST.cc +++ b/paludis/elike_dep_parser_TEST.cc @@ -18,15 +18,15 @@ */ #include <paludis/elike_dep_parser.hh> + #include <paludis/util/map.hh> #include <paludis/util/wrapped_forward_iterator.hh> #include <paludis/util/make_named_values.hh> #include <paludis/util/options.hh> -#include <test/test_framework.hh> -#include <test/test_runner.hh> + +#include <gtest/gtest.h> using namespace paludis; -using namespace test; namespace { @@ -54,122 +54,99 @@ namespace } } -namespace test_cases +TEST(ELikeDepParser, Basic) { - struct ELikeDepParserBasicTest : TestCase - { - ELikeDepParserBasicTest() : TestCase("basic") { } - - void run() - { - using namespace std::placeholders; - - std::string in("|| ( a b ( c d e ) )"), out; - ELikeDepParserCallbacks callbacks(make_named_values<ELikeDepParserCallbacks>( - n::on_all() = std::bind(&handler, std::ref(out), "all<", "", "", "", ""), - n::on_annotations() = std::bind(&handle_annotations, std::ref(out), _1), - n::on_any() = std::bind(&handler, std::ref(out), "any<", "", "", "", ""), - n::on_arrow() = std::bind(&handler, std::ref(out), "a<", _1, ", ", _2, ">"), - n::on_error() = std::bind(&handler, std::ref(out), "error<", _1, ">", "", ""), - n::on_exactly_one() = std::bind(&handler, std::ref(out), "x<", "", "", "", ""), - n::on_label() = std::bind(&handler, std::ref(out), "label<", _1, "", "", ""), - n::on_no_annotations() = &do_nothing, - n::on_pop() = std::bind(&handler, std::ref(out), ">", "", "", "", ""), - n::on_should_be_empty() = std::bind(&handler, std::ref(out), "EMPTY", "", "", "", ""), - n::on_string() = std::bind(&handler, std::ref(out), "s<", _1, ">", "", ""), - n::on_use() = std::bind(&handler, std::ref(out), "use<", _1, ", ", "", ""), - n::on_use_under_any() = &do_nothing - )); - parse_elike_dependencies(in, callbacks, { }); - TEST_CHECK_EQUAL(out, "any<s<a>s<b>all<s<c>s<d>s<e>>>EMPTY"); - } - } elike_dep_parser_basic_test; - - struct ELikeDepParserEmptyBlocksTest : TestCase - { - ELikeDepParserEmptyBlocksTest() : TestCase("empty blocks") { } - - void run() - { - using namespace std::placeholders; - - std::string in("( ( ) )"), out; - ELikeDepParserCallbacks callbacks(make_named_values<ELikeDepParserCallbacks>( - n::on_all() = std::bind(&handler, std::ref(out), "all<", "", "", "", ""), - n::on_annotations() = std::bind(&handle_annotations, std::ref(out), _1), - n::on_any() = std::bind(&handler, std::ref(out), "any<", "", "", "", ""), - n::on_arrow() = std::bind(&handler, std::ref(out), "a<", _1, ", ", _2, ">"), - n::on_error() = std::bind(&handler, std::ref(out), "error<", _1, ">", "", ""), - n::on_exactly_one() = std::bind(&handler, std::ref(out), "x<", "", "", "", ""), - n::on_label() = std::bind(&handler, std::ref(out), "label<", _1, "", "", ""), - n::on_no_annotations() = &do_nothing, - n::on_pop() = std::bind(&handler, std::ref(out), ">", "", "", "", ""), - n::on_should_be_empty() = std::bind(&handler, std::ref(out), "EMPTY", "", "", "", ""), - n::on_string() = std::bind(&handler, std::ref(out), "s<", _1, ">", "", ""), - n::on_use() = std::bind(&handler, std::ref(out), "use<", _1, ", ", "", ""), - n::on_use_under_any() = &do_nothing - )); - parse_elike_dependencies(in, callbacks, { }); - TEST_CHECK_EQUAL(out, "all<all<>>EMPTY"); - } - } elike_dep_parser_test_empty_blocks; - - struct ELikeDepParserAnnotationsTest : TestCase - { - ELikeDepParserAnnotationsTest() : TestCase("annotations") { } - - void run() - { - using namespace std::placeholders; - - std::string in("a [[ first = foo second = [ bar baz ] ]]"), out; - ELikeDepParserCallbacks callbacks(make_named_values<ELikeDepParserCallbacks>( - n::on_all() = std::bind(&handler, std::ref(out), "all<", "", "", "", ""), - n::on_annotations() = std::bind(&handle_annotations, std::ref(out), _1), - n::on_any() = std::bind(&handler, std::ref(out), "any<", "", "", "", ""), - n::on_arrow() = std::bind(&handler, std::ref(out), "a<", _1, ", ", _2, ">"), - n::on_error() = std::bind(&handler, std::ref(out), "error<", _1, ">", "", ""), - n::on_exactly_one() = std::bind(&handler, std::ref(out), "x<", "", "", "", ""), - n::on_label() = std::bind(&handler, std::ref(out), "label<", _1, "", "", ""), - n::on_no_annotations() = &do_nothing, - n::on_pop() = std::bind(&handler, std::ref(out), ">", "", "", "", ""), - n::on_should_be_empty() = std::bind(&handler, std::ref(out), "EMPTY", "", "", "", ""), - n::on_string() = std::bind(&handler, std::ref(out), "s<", _1, ">", "", ""), - n::on_use() = std::bind(&handler, std::ref(out), "use<", _1, ", ", "", ""), - n::on_use_under_any() = &do_nothing - )); - parse_elike_dependencies(in, callbacks, { }); - TEST_CHECK_EQUAL(out, "s<a>[first:foo;second:bar baz;]EMPTY"); - } - } elike_dep_parser_annotations_test; - - struct ELikeDepParserCommentsTest : TestCase - { - ELikeDepParserCommentsTest() : TestCase("comments") { } - - void run() - { - using namespace std::placeholders; - - std::string in("# comment\na [[ first = foo second = [ bar baz ] ]] # comment"), out; - ELikeDepParserCallbacks callbacks(make_named_values<ELikeDepParserCallbacks>( - n::on_all() = std::bind(&handler, std::ref(out), "all<", "", "", "", ""), - n::on_annotations() = std::bind(&handle_annotations, std::ref(out), _1), - n::on_any() = std::bind(&handler, std::ref(out), "any<", "", "", "", ""), - n::on_arrow() = std::bind(&handler, std::ref(out), "a<", _1, ", ", _2, ">"), - n::on_error() = std::bind(&handler, std::ref(out), "error<", _1, ">", "", ""), - n::on_exactly_one() = std::bind(&handler, std::ref(out), "x<", "", "", "", ""), - n::on_label() = std::bind(&handler, std::ref(out), "label<", _1, "", "", ""), - n::on_no_annotations() = &do_nothing, - n::on_pop() = std::bind(&handler, std::ref(out), ">", "", "", "", ""), - n::on_should_be_empty() = std::bind(&handler, std::ref(out), "EMPTY", "", "", "", ""), - n::on_string() = std::bind(&handler, std::ref(out), "s<", _1, ">", "", ""), - n::on_use() = std::bind(&handler, std::ref(out), "use<", _1, ", ", "", ""), - n::on_use_under_any() = &do_nothing - )); - parse_elike_dependencies(in, callbacks, { edpo_allow_embedded_comments }); - TEST_CHECK_EQUAL(out, "s<a>[first:foo;second:bar baz;]EMPTY"); - } - } elike_dep_parser_comments_test; + using namespace std::placeholders; + + std::string in("|| ( a b ( c d e ) )"), out; + ELikeDepParserCallbacks callbacks(make_named_values<ELikeDepParserCallbacks>( + n::on_all() = std::bind(&handler, std::ref(out), "all<", "", "", "", ""), + n::on_annotations() = std::bind(&handle_annotations, std::ref(out), _1), + n::on_any() = std::bind(&handler, std::ref(out), "any<", "", "", "", ""), + n::on_arrow() = std::bind(&handler, std::ref(out), "a<", _1, ", ", _2, ">"), + n::on_error() = std::bind(&handler, std::ref(out), "error<", _1, ">", "", ""), + n::on_exactly_one() = std::bind(&handler, std::ref(out), "x<", "", "", "", ""), + n::on_label() = std::bind(&handler, std::ref(out), "label<", _1, "", "", ""), + n::on_no_annotations() = &do_nothing, + n::on_pop() = std::bind(&handler, std::ref(out), ">", "", "", "", ""), + n::on_should_be_empty() = std::bind(&handler, std::ref(out), "EMPTY", "", "", "", ""), + n::on_string() = std::bind(&handler, std::ref(out), "s<", _1, ">", "", ""), + n::on_use() = std::bind(&handler, std::ref(out), "use<", _1, ", ", "", ""), + n::on_use_under_any() = &do_nothing + )); + parse_elike_dependencies(in, callbacks, { }); + EXPECT_EQ("any<s<a>s<b>all<s<c>s<d>s<e>>>EMPTY", out); +} + +TEST(ELikeDepParser, Empty) +{ + using namespace std::placeholders; + + std::string in("( ( ) )"), out; + ELikeDepParserCallbacks callbacks(make_named_values<ELikeDepParserCallbacks>( + n::on_all() = std::bind(&handler, std::ref(out), "all<", "", "", "", ""), + n::on_annotations() = std::bind(&handle_annotations, std::ref(out), _1), + n::on_any() = std::bind(&handler, std::ref(out), "any<", "", "", "", ""), + n::on_arrow() = std::bind(&handler, std::ref(out), "a<", _1, ", ", _2, ">"), + n::on_error() = std::bind(&handler, std::ref(out), "error<", _1, ">", "", ""), + n::on_exactly_one() = std::bind(&handler, std::ref(out), "x<", "", "", "", ""), + n::on_label() = std::bind(&handler, std::ref(out), "label<", _1, "", "", ""), + n::on_no_annotations() = &do_nothing, + n::on_pop() = std::bind(&handler, std::ref(out), ">", "", "", "", ""), + n::on_should_be_empty() = std::bind(&handler, std::ref(out), "EMPTY", "", "", "", ""), + n::on_string() = std::bind(&handler, std::ref(out), "s<", _1, ">", "", ""), + n::on_use() = std::bind(&handler, std::ref(out), "use<", _1, ", ", "", ""), + n::on_use_under_any() = &do_nothing + )); + parse_elike_dependencies(in, callbacks, { }); + EXPECT_EQ("all<all<>>EMPTY", out); +} + +TEST(ELikeDepParser, Annotations) +{ + using namespace std::placeholders; + + std::string in("a [[ first = foo second = [ bar baz ] ]]"), out; + ELikeDepParserCallbacks callbacks(make_named_values<ELikeDepParserCallbacks>( + n::on_all() = std::bind(&handler, std::ref(out), "all<", "", "", "", ""), + n::on_annotations() = std::bind(&handle_annotations, std::ref(out), _1), + n::on_any() = std::bind(&handler, std::ref(out), "any<", "", "", "", ""), + n::on_arrow() = std::bind(&handler, std::ref(out), "a<", _1, ", ", _2, ">"), + n::on_error() = std::bind(&handler, std::ref(out), "error<", _1, ">", "", ""), + n::on_exactly_one() = std::bind(&handler, std::ref(out), "x<", "", "", "", ""), + n::on_label() = std::bind(&handler, std::ref(out), "label<", _1, "", "", ""), + n::on_no_annotations() = &do_nothing, + n::on_pop() = std::bind(&handler, std::ref(out), ">", "", "", "", ""), + n::on_should_be_empty() = std::bind(&handler, std::ref(out), "EMPTY", "", "", "", ""), + n::on_string() = std::bind(&handler, std::ref(out), "s<", _1, ">", "", ""), + n::on_use() = std::bind(&handler, std::ref(out), "use<", _1, ", ", "", ""), + n::on_use_under_any() = &do_nothing + )); + parse_elike_dependencies(in, callbacks, { }); + EXPECT_EQ("s<a>[first:foo;second:bar baz;]EMPTY", out); +} + +TEST(ELikeDepParser, Comments) +{ + using namespace std::placeholders; + + std::string in("# comment\na [[ first = foo second = [ bar baz ] ]] # comment"), out; + ELikeDepParserCallbacks callbacks(make_named_values<ELikeDepParserCallbacks>( + n::on_all() = std::bind(&handler, std::ref(out), "all<", "", "", "", ""), + n::on_annotations() = std::bind(&handle_annotations, std::ref(out), _1), + n::on_any() = std::bind(&handler, std::ref(out), "any<", "", "", "", ""), + n::on_arrow() = std::bind(&handler, std::ref(out), "a<", _1, ", ", _2, ">"), + n::on_error() = std::bind(&handler, std::ref(out), "error<", _1, ">", "", ""), + n::on_exactly_one() = std::bind(&handler, std::ref(out), "x<", "", "", "", ""), + n::on_label() = std::bind(&handler, std::ref(out), "label<", _1, "", "", ""), + n::on_no_annotations() = &do_nothing, + n::on_pop() = std::bind(&handler, std::ref(out), ">", "", "", "", ""), + n::on_should_be_empty() = std::bind(&handler, std::ref(out), "EMPTY", "", "", "", ""), + n::on_string() = std::bind(&handler, std::ref(out), "s<", _1, ">", "", ""), + n::on_use() = std::bind(&handler, std::ref(out), "use<", _1, ", ", "", ""), + n::on_use_under_any() = &do_nothing + )); + parse_elike_dependencies(in, callbacks, { edpo_allow_embedded_comments }); + EXPECT_EQ("s<a>[first:foo;second:bar baz;]EMPTY", out); } diff --git a/paludis/files.m4 b/paludis/files.m4 index 10290fbce..2e92e5111 100644 --- a/paludis/files.m4 +++ b/paludis/files.m4 @@ -35,7 +35,7 @@ add(`distribution', `hh', `cc', `impl', `fwd') add(`elf_linkage_checker', `hh', `cc') add(`elike_blocker', `hh', `cc', `fwd', `se') add(`elike_choices', `hh', `cc', `fwd', `se') -add(`elike_dep_parser', `hh', `cc', `fwd', `test', `se') +add(`elike_dep_parser', `hh', `cc', `fwd', `gtest', `se') add(`elike_conditional_dep_spec', `hh', `cc', `fwd') add(`elike_package_dep_spec', `hh', `cc', `fwd', `se') add(`elike_slot_requirement', `hh', `cc', `fwd') |