From a2cc3deb5c0ff25a61f874743197a48d29dbb5c9 Mon Sep 17 00:00:00 2001 From: Federico De Felici Date: Sun, 21 Apr 2024 10:54:40 +0200 Subject: [PATCH 1/3] #100 add temporary test --- .../functs/src/unit/report_pretty_full_test.c | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/tests/functs/src/unit/report_pretty_full_test.c b/tests/functs/src/unit/report_pretty_full_test.c index ff876a0..ea0c2b6 100644 --- a/tests/functs/src/unit/report_pretty_full_test.c +++ b/tests/functs/src/unit/report_pretty_full_test.c @@ -67,6 +67,35 @@ CLOVE_TEST(ReportOneSuiteWithOnePassedTest) { CLOVE_STRING_EQ(expected, actual); } +CLOVE_TEST(ReportWithTestNameLongerThanSuiteName) { + __clove_suite_t suite = create_suite("bl_blitters"); + __clove_test_t test11 = create_test("bl_blitters_select_color__blit_color"); + //bl_blitters.bl_blitters_select_color__blit_color_blend + + suite_add_test(&suite, &test11); + __CLOVE_VECTOR_ADD(&suites, __clove_suite_t, suite); + + __clove_report_t* base = (__clove_report_t*)report; + base->start(base, &suites, 1); + base->begin_suite(base, &suite, 0); + base->end_test(base, &suite, &test11, 1); + base->end_suite(base, &suite, 0); + base->end(base, 1, 0, 0); + + const char* expected = + "[INFO] Executing Test Runner with detail level: 'Full'\n" + "[INFO] Suites / Tests found: 1 / 1\n" + "[INFO] 1) bl_blitters.bl_blitters_select_color__blit_color..[PASS] (0.000 ms)\n" + "[INFO] Total: 1, Passed: 1, Failed: 0, Skipped: 0\n" + "[INFO] Run duration: 0 ms\n" + "[INFO] Run result: SUCCESS :-)\n" + ; + + char* actual = __clove_stream_memory_as_string(stream); + + CLOVE_STRING_EQ(expected, actual); +} + CLOVE_TEST(ReportOneSuiteWithTwoTests) { __clove_suite_t suite = create_suite("Suite1"); __clove_test_t test11 = create_test("Test11"); From 7f0dacc51fa69ea4e669fd31b165b523b7c6c73b Mon Sep 17 00:00:00 2001 From: Federico De Felici Date: Sun, 21 Apr 2024 16:19:19 +0200 Subject: [PATCH 2/3] fix #100 --- clove-unit.h | 2 +- .../functs/src/unit/report_pretty_full_test.c | 113 +++++++++++++----- 2 files changed, 85 insertions(+), 30 deletions(-) diff --git a/clove-unit.h b/clove-unit.h index 7936c0f..6c2a1bb 100644 --- a/clove-unit.h +++ b/clove-unit.h @@ -2662,7 +2662,7 @@ void __clove_report_pretty_start(__clove_report_t* _this, __clove_vector_t* suit size_t longest_suite_and_test_name = 0; __CLOVE_VECTOR_FOREACH(suites, __clove_suite_t, each_suite, { size_t suite_length = __clove_string_length(each_suite->name); - __CLOVE_VECTOR_FOREACH(suites, __clove_test_t, each_test, { + __CLOVE_VECTOR_FOREACH(&each_suite->tests, __clove_test_t, each_test, { size_t test_length = __clove_string_length(each_test->name); if (longest_suite_and_test_name < suite_length + test_length) { diff --git a/tests/functs/src/unit/report_pretty_full_test.c b/tests/functs/src/unit/report_pretty_full_test.c index ea0c2b6..b510680 100644 --- a/tests/functs/src/unit/report_pretty_full_test.c +++ b/tests/functs/src/unit/report_pretty_full_test.c @@ -67,35 +67,6 @@ CLOVE_TEST(ReportOneSuiteWithOnePassedTest) { CLOVE_STRING_EQ(expected, actual); } -CLOVE_TEST(ReportWithTestNameLongerThanSuiteName) { - __clove_suite_t suite = create_suite("bl_blitters"); - __clove_test_t test11 = create_test("bl_blitters_select_color__blit_color"); - //bl_blitters.bl_blitters_select_color__blit_color_blend - - suite_add_test(&suite, &test11); - __CLOVE_VECTOR_ADD(&suites, __clove_suite_t, suite); - - __clove_report_t* base = (__clove_report_t*)report; - base->start(base, &suites, 1); - base->begin_suite(base, &suite, 0); - base->end_test(base, &suite, &test11, 1); - base->end_suite(base, &suite, 0); - base->end(base, 1, 0, 0); - - const char* expected = - "[INFO] Executing Test Runner with detail level: 'Full'\n" - "[INFO] Suites / Tests found: 1 / 1\n" - "[INFO] 1) bl_blitters.bl_blitters_select_color__blit_color..[PASS] (0.000 ms)\n" - "[INFO] Total: 1, Passed: 1, Failed: 0, Skipped: 0\n" - "[INFO] Run duration: 0 ms\n" - "[INFO] Run result: SUCCESS :-)\n" - ; - - char* actual = __clove_stream_memory_as_string(stream); - - CLOVE_STRING_EQ(expected, actual); -} - CLOVE_TEST(ReportOneSuiteWithTwoTests) { __clove_suite_t suite = create_suite("Suite1"); __clove_test_t test11 = create_test("Test11"); @@ -232,3 +203,87 @@ CLOVE_TEST(ReportTwoSuitesWithTenTests) { CLOVE_STRING_EQ(expected, actual); } + +CLOVE_TEST(ReportWithTestIdentifierLength45) { + __clove_suite_t suite = create_suite("Suite12345"); + __clove_test_t test11 = create_test("Suite12345_Test1234567890__1234567"); + + suite_add_test(&suite, &test11); + __CLOVE_VECTOR_ADD(&suites, __clove_suite_t, suite); + + __clove_report_t* base = (__clove_report_t*)report; + base->start(base, &suites, 1); + base->begin_suite(base, &suite, 0); + base->end_test(base, &suite, &test11, 1); + base->end_suite(base, &suite, 0); + base->end(base, 1, 0, 0); + + const char* expected = + "[INFO] Executing Test Runner with detail level: 'Full'\n" + "[INFO] Suites / Tests found: 1 / 1\n" + "[INFO] 1) Suite12345.Suite12345_Test1234567890__1234567.....[PASS] (0.000 ms)\n" + "[INFO] Total: 1, Passed: 1, Failed: 0, Skipped: 0\n" + "[INFO] Run duration: 0 ms\n" + "[INFO] Run result: SUCCESS :-)\n" + ; + + char* actual = __clove_stream_memory_as_string(stream); + + CLOVE_STRING_EQ(expected, actual); +} + +CLOVE_TEST(ReportWithTestIdentifierLength48) { + __clove_suite_t suite = create_suite("Suite12345"); + __clove_test_t test11 = create_test("Suite12345_Test1234567890__1234567890"); + + suite_add_test(&suite, &test11); + __CLOVE_VECTOR_ADD(&suites, __clove_suite_t, suite); + + __clove_report_t* base = (__clove_report_t*)report; + base->start(base, &suites, 1); + base->begin_suite(base, &suite, 0); + base->end_test(base, &suite, &test11, 1); + base->end_suite(base, &suite, 0); + base->end(base, 1, 0, 0); + + const char* expected = + "[INFO] Executing Test Runner with detail level: 'Full'\n" + "[INFO] Suites / Tests found: 1 / 1\n" + "[INFO] 1) Suite12345.Suite12345_Test1234567890__1234567890...[PASS] (0.000 ms)\n" + "[INFO] Total: 1, Passed: 1, Failed: 0, Skipped: 0\n" + "[INFO] Run duration: 0 ms\n" + "[INFO] Run result: SUCCESS :-)\n" + ; + + char* actual = __clove_stream_memory_as_string(stream); + + CLOVE_STRING_EQ(expected, actual); +} + +CLOVE_TEST(ReportWithTestIdentifierLength50) { + __clove_suite_t suite = create_suite("Suite12345"); + __clove_test_t test11 = create_test("Suite12345_Test1234567890__123456789012"); + + suite_add_test(&suite, &test11); + __CLOVE_VECTOR_ADD(&suites, __clove_suite_t, suite); + + __clove_report_t* base = (__clove_report_t*)report; + base->start(base, &suites, 1); + base->begin_suite(base, &suite, 0); + base->end_test(base, &suite, &test11, 1); + base->end_suite(base, &suite, 0); + base->end(base, 1, 0, 0); + + const char* expected = + "[INFO] Executing Test Runner with detail level: 'Full'\n" + "[INFO] Suites / Tests found: 1 / 1\n" + "[INFO] 1) Suite12345.Suite12345_Test1234567890__123456789012...[PASS] (0.000 ms)\n" + "[INFO] Total: 1, Passed: 1, Failed: 0, Skipped: 0\n" + "[INFO] Run duration: 0 ms\n" + "[INFO] Run result: SUCCESS :-)\n" + ; + + char* actual = __clove_stream_memory_as_string(stream); + + CLOVE_STRING_EQ(expected, actual); +} \ No newline at end of file From b07927dafde2fff3815929555ad0b12dd6721af5 Mon Sep 17 00:00:00 2001 From: Federico De Felici Date: Sun, 21 Apr 2024 16:23:40 +0200 Subject: [PATCH 3/3] prepare release v.2.4.4 --- clove-unit.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/clove-unit.h b/clove-unit.h index 6c2a1bb..a88008d 100644 --- a/clove-unit.h +++ b/clove-unit.h @@ -1,6 +1,6 @@ /* * clove-unit - * v2.4.3 + * v2.4.4 * Single-Header Unit Testing library for C/C++ * https://github.com/fdefelici/clove-unit * @@ -10,8 +10,8 @@ #define __CLOVE_VERSION_MAJOR 2 #define __CLOVE_VERSION_MINOR 4 -#define __CLOVE_VERSION_PATCH 3 -#define __CLOVE_VERSION "2.4.3" +#define __CLOVE_VERSION_PATCH 4 +#define __CLOVE_VERSION "2.4.4" //Preventing "unknown-pragmas" warning on GCC <= 12 for '#pragma region' usage //NOTE1: GCC and G++ v13+ support '#pragma region' by the way.