Skip to content

Commit

Permalink
fix some problems with the declaration/definition of test groups
Browse files Browse the repository at this point in the history
  • Loading branch information
biojppm committed Mar 29, 2024
1 parent b3c05eb commit 94c249a
Show file tree
Hide file tree
Showing 34 changed files with 273 additions and 21 deletions.
24 changes: 12 additions & 12 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,25 +39,28 @@ function(ryml_add_test test_name)
endfunction()


c4_add_library(ryml-_testgroup LIBRARY_TYPE OBJECT
SOURCES test_lib/test_group.cpp test_lib/test_group.hpp
c4_add_library(ryml-_testgroup LIBRARY_TYPE STATIC
SOURCES
test_lib/test_group.hpp
test_lib/test_group.def.hpp
test_lib/test_group.cpp
LIBS ryml ryml-_testlib c4fs
FOLDER test)
function(ryml_add_test_case_group name)
ryml_add_test(${name})
target_link_directories(ryml-test-${name} PUBLIC ryml-_testgroup)
target_link_libraries(ryml-test-${name} PUBLIC ryml-_testgroup)
endfunction()


# FIXME: during this large refactor, some tests are disabled
# and will be progressively reenabled as the refactor proceeds

ryml_add_test(callbacks)
ryml_add_test(stack)
ryml_add_test(filter)
ryml_add_test(parse_engine
test_suite/test_suite_event_handler.cpp
test_suite/test_suite_event_handler.hpp)
ryml_add_test(yaml_events
test_suite/test_suite_event_handler.cpp
test_suite/test_suite_event_handler.hpp)
ryml_add_test(callbacks)
ryml_add_test(stack)
ryml_add_test(filter)
ryml_add_test(parser)
ryml_add_test(tree)
ryml_add_test(noderef)
Expand All @@ -69,9 +72,6 @@ ryml_add_test(json)
ryml_add_test(preprocess)
ryml_add_test(merge)
ryml_add_test(location)
ryml_add_test(yaml_events
test_suite/test_suite_event_handler.cpp
test_suite/test_suite_event_handler.hpp)
ryml_add_test_case_group(empty_file)
ryml_add_test_case_group(doc)
ryml_add_test_case_group(seq)
Expand Down
1 change: 1 addition & 0 deletions test/test_anchor.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "./test_lib/test_group.hpp"
#include "./test_lib/test_group.def.hpp"

namespace c4 {
namespace yml {
Expand Down
1 change: 1 addition & 0 deletions test/test_doc.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "./test_lib/test_group.hpp"
#include "./test_lib/test_group.def.hpp"

namespace c4 {
namespace yml {
Expand Down
1 change: 1 addition & 0 deletions test/test_empty_file.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "./test_lib/test_group.hpp"
#include "./test_lib/test_group.def.hpp"

namespace c4 {
namespace yml {
Expand Down
1 change: 1 addition & 0 deletions test/test_explicit_key.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "./test_lib/test_group.hpp"
#include "./test_lib/test_group.def.hpp"

namespace c4 {
namespace yml {
Expand Down
1 change: 1 addition & 0 deletions test/test_github_issues.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "./test_lib/test_group.hpp"
#include "./test_lib/test_group.def.hpp"

namespace c4 {
namespace yml {
Expand Down
1 change: 1 addition & 0 deletions test/test_indentation.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "./test_lib/test_group.hpp"
#include "./test_lib/test_group.def.hpp"

namespace c4 {
namespace yml {
Expand Down
223 changes: 223 additions & 0 deletions test/test_lib/test_group.def.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,223 @@
#ifndef _C4_YML_TEST_TEST_GROUP_TEST_GROUP_DEF_HPP_
#define _C4_YML_TEST_TEST_GROUP_TEST_GROUP_DEF_HPP_

namespace c4 {
namespace yml {

int YmlTestCaseDefsWereIncluded() { return 42; }

//-----------------------------------------------------------------------------

TEST_P(YmlTestCase, parse_unix)
{
SCOPED_TRACE("unix style\n" + c->filelinebuf + ": case");
_test_parse_using_ryml(&d->unix_style);
}

TEST_P(YmlTestCase, parse_windows)
{
SCOPED_TRACE("windows style\n" + c->filelinebuf + ": case");
_test_parse_using_ryml(&d->windows_style);
}

//-----------------------------------------------------------------------------
TEST_P(YmlTestCase, emit_yml_unix_stdout)
{
SCOPED_TRACE("unix style\n" + c->filelinebuf + ": case");
_test_emit_yml_stdout(&d->unix_style);
}
TEST_P(YmlTestCase, emit_json_unix_stdout)
{
SCOPED_TRACE("unix style json\n" + c->filelinebuf + ": case");
_test_emit_json_stdout(&d->unix_style_json);
}

TEST_P(YmlTestCase, emit_yml_windows_stdout)
{
SCOPED_TRACE("windows style\n" + c->filelinebuf + ": case");
_test_emit_yml_stdout(&d->windows_style);
}
TEST_P(YmlTestCase, emit_json_windows_stdout)
{
SCOPED_TRACE("windows style json\n" + c->filelinebuf + ": case");
_test_emit_json_stdout(&d->windows_style_json);
}

//-----------------------------------------------------------------------------
TEST_P(YmlTestCase, emit_yml_unix_cout)
{
SCOPED_TRACE("unix style\n" + c->filelinebuf + ": case");
_test_emit_yml_cout(&d->unix_style);
}
TEST_P(YmlTestCase, emit_json_unix_cout)
{
SCOPED_TRACE("unix style json\n" + c->filelinebuf + ": case");
_test_emit_json_cout(&d->unix_style_json);
}

TEST_P(YmlTestCase, emit_yml_windows_cout)
{
SCOPED_TRACE("windows style\n" + c->filelinebuf + ": case");
_test_emit_yml_cout(&d->windows_style);
}
TEST_P(YmlTestCase, emit_json_windows_cout)
{
SCOPED_TRACE("windows style json\n" + c->filelinebuf + ": case");
_test_emit_json_cout(&d->windows_style_json);
}

//-----------------------------------------------------------------------------
TEST_P(YmlTestCase, emit_yml_unix_stringstream)
{
SCOPED_TRACE("unix style\n" + c->filelinebuf + ": case");
_test_emit_yml_stringstream(&d->unix_style);
}
TEST_P(YmlTestCase, emit_json_unix_stringstream)
{
SCOPED_TRACE("unix style json\n" + c->filelinebuf + ": case");
_test_emit_json_stringstream(&d->unix_style_json);
}

TEST_P(YmlTestCase, emit_yml_windows_stringstream)
{
SCOPED_TRACE("windows style\n" + c->filelinebuf + ": case");
_test_emit_yml_stringstream(&d->windows_style);
}
TEST_P(YmlTestCase, emit_json_windows_stringstream)
{
SCOPED_TRACE("windows style json\n" + c->filelinebuf + ": case");
_test_emit_json_stringstream(&d->windows_style_json);
}

//-----------------------------------------------------------------------------
TEST_P(YmlTestCase, emit_yml_unix_ofstream)
{
SCOPED_TRACE("unix style\n" + c->filelinebuf + ": case");
_test_emit_yml_ofstream(&d->unix_style);
}
TEST_P(YmlTestCase, emit_json_unix_ofstream)
{
SCOPED_TRACE("unix style json\n" + c->filelinebuf + ": case");
_test_emit_json_ofstream(&d->unix_style_json);
}

TEST_P(YmlTestCase, emit_yml_windows_ofstream)
{
SCOPED_TRACE("windows style\n" + c->filelinebuf + ": case");
_test_emit_yml_ofstream(&d->windows_style);
}
TEST_P(YmlTestCase, emit_json_windows_ofstream)
{
SCOPED_TRACE("windows style json\n" + c->filelinebuf + ": case");
_test_emit_json_ofstream(&d->windows_style_json);
}

//-----------------------------------------------------------------------------
TEST_P(YmlTestCase, emit_yml_unix_string)
{
SCOPED_TRACE("unix style\n" + c->filelinebuf + ": case");
_test_emit_yml_string(&d->unix_style);
}
TEST_P(YmlTestCase, emit_json_unix_string)
{
SCOPED_TRACE("unix style json\n" + c->filelinebuf + ": case");
_test_emit_json_string(&d->unix_style_json);
}

TEST_P(YmlTestCase, emit_yml_windows_string)
{
SCOPED_TRACE("windows style\n" + c->filelinebuf + ": case");
_test_emit_yml_string(&d->windows_style);
}
TEST_P(YmlTestCase, emit_json_windows_string)
{
SCOPED_TRACE("windows style json\n" + c->filelinebuf + ": case");
_test_emit_json_string(&d->windows_style_json);
}

//-----------------------------------------------------------------------------
TEST_P(YmlTestCase, unix_emitrs)
{
SCOPED_TRACE("unix style\n" + c->filelinebuf + ": case");
_test_emitrs(&d->unix_style);
}
TEST_P(YmlTestCase, unix_emitrs_json)
{
SCOPED_TRACE("unix style json\n" + c->filelinebuf + ": case");
_test_emitrs_json(&d->unix_style_json);
}

TEST_P(YmlTestCase, windows_emitrs)
{
SCOPED_TRACE("windows style\n" + c->filelinebuf + ": case");
_test_emitrs(&d->windows_style);
}
TEST_P(YmlTestCase, windows_emitrs_json)
{
SCOPED_TRACE("windows style json\n" + c->filelinebuf + ": case");
_test_emitrs_json(&d->windows_style_json);
}

//-----------------------------------------------------------------------------
TEST_P(YmlTestCase, unix_emitrs_cfile)
{
SCOPED_TRACE("unix style\n" + c->filelinebuf + ": case");
_test_emitrs_cfile(&d->unix_style);
}
TEST_P(YmlTestCase, unix_emitrs_json_cfile)
{
SCOPED_TRACE("unix style json\n" + c->filelinebuf + ": case");
_test_emitrs_json_cfile(&d->unix_style_json);
}

TEST_P(YmlTestCase, windows_emitrs_cfile)
{
SCOPED_TRACE("windows style\n" + c->filelinebuf + ": case");
_test_emitrs_cfile(&d->windows_style);
}
TEST_P(YmlTestCase, windows_emitrs_json_cfile)
{
SCOPED_TRACE("windows style json\n" + c->filelinebuf + ": case");
_test_emitrs_json_cfile(&d->windows_style_json);
}

//-----------------------------------------------------------------------------
TEST_P(YmlTestCase, complete_unix_round_trip)
{
SCOPED_TRACE("unix style:\n" + c->filelinebuf + ": case");
_test_complete_round_trip(&d->unix_style);
}
TEST_P(YmlTestCase, complete_unix_round_trip_json)
{
SCOPED_TRACE("unix style json\n" + c->filelinebuf + ": case");
_test_complete_round_trip_json(&d->unix_style_json);
}

TEST_P(YmlTestCase, complete_windows_round_trip)
{
SCOPED_TRACE("windows style\n" + c->filelinebuf + ": case");
_test_complete_round_trip(&d->windows_style);
}
TEST_P(YmlTestCase, complete_windows_round_trip_json)
{
SCOPED_TRACE("windows style json\n" + c->filelinebuf + ": case");
_test_complete_round_trip_json(&d->windows_style_json);
}

//-----------------------------------------------------------------------------
TEST_P(YmlTestCase, unix_recreate_from_ref)
{
SCOPED_TRACE("unix style\n" + c->filelinebuf + ": case");
_test_recreate_from_ref(&d->unix_style);
}

TEST_P(YmlTestCase, windows_recreate_from_ref)
{
SCOPED_TRACE("windows style\n" + c->filelinebuf + ": case");
_test_recreate_from_ref(&d->windows_style);
}

} // namespace c4
} // namespace yml

#endif // _C4_YML_TEST_TEST_GROUP_TEST_GROUP_DEF_HPP_
2 changes: 1 addition & 1 deletion test/test_lib/test_group.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ Case const* get_case(csubstr name) \
printf("case not found: '%.*s' defs_included=%d\n", \
(int)name.len, name.str, \
/*call this function to ensure the tests were included*/ \
YmlTestCaseWereDefsrrIncluded()); \
YmlTestCaseDefsWereIncluded()); \
C4_ERROR("case not found: '%.*s'", (int)name.len, name.str); \
return nullptr; \
} \
Expand Down
2 changes: 1 addition & 1 deletion test/test_map.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "./test_lib/test_group.hpp"
#include "./test_lib/test_group.def.hpp"

namespace c4 {
namespace yml {
Expand Down Expand Up @@ -693,7 +694,6 @@ TEST(simple_map, tokens_after_flow_11_1)
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------


CASE_GROUP(SIMPLE_MAP)
{
//
Expand Down
1 change: 1 addition & 0 deletions test/test_map_empty.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "./test_lib/test_group.hpp"
#include "test_lib/test_group.def.hpp"

namespace c4 {
namespace yml {
Expand Down
1 change: 1 addition & 0 deletions test/test_map_generic.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "./test_lib/test_group.hpp"
#include "./test_lib/test_group.def.hpp"

namespace c4 {
namespace yml {
Expand Down
1 change: 1 addition & 0 deletions test/test_map_nestedx2.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "./test_lib/test_group.hpp"
#include "./test_lib/test_group.def.hpp"

namespace c4 {
namespace yml {
Expand Down
1 change: 1 addition & 0 deletions test/test_map_nestedx3.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "./test_lib/test_group.hpp"
#include "./test_lib/test_group.def.hpp"

namespace c4 {
namespace yml {
Expand Down
1 change: 1 addition & 0 deletions test/test_map_nestedx4.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "./test_lib/test_group.hpp"
#include "./test_lib/test_group.def.hpp"

namespace c4 {
namespace yml {
Expand Down
1 change: 1 addition & 0 deletions test/test_map_of_seq.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "./test_lib/test_group.hpp"
#include "./test_lib/test_group.def.hpp"

namespace c4 {
namespace yml {
Expand Down
1 change: 1 addition & 0 deletions test/test_map_set.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "./test_lib/test_group.hpp"
#include "./test_lib/test_group.def.hpp"

namespace c4 {
namespace yml {
Expand Down
Loading

0 comments on commit 94c249a

Please sign in to comment.