From 2a10eaae094e48a157d55ec886aaa07b0d0be6c9 Mon Sep 17 00:00:00 2001 From: Steven Le Rouzic Date: Mon, 28 Oct 2024 23:52:48 +0100 Subject: Some work on test framework & option --- asl/tests/format_tests.cpp | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'asl/tests/format_tests.cpp') diff --git a/asl/tests/format_tests.cpp b/asl/tests/format_tests.cpp index 6e2430d..f4ca2cf 100644 --- a/asl/tests/format_tests.cpp +++ b/asl/tests/format_tests.cpp @@ -1,4 +1,5 @@ #include "asl/format.hpp" +#include "asl/testing/testing.hpp" #include #include @@ -33,74 +34,73 @@ public: } }; -int main2() +ASL_TEST(Format) { StringSink sink; - // @Todo Use the testing framework + // @Todo Introduce ASL_TEST_ASSERT_EQ, or ASL_TEST_ASSERT_STREQ + // @Todo Don't use strcmp for string comparison asl::format(&sink, "Hello, world!"); - assert(strcmp(sink.cstr(), "Hello, world!") == 0); + ASL_TEST_ASSERT(strcmp(sink.cstr(), "Hello, world!") == 0); sink.reset(); asl::format(&sink, ""); - assert(strcmp(sink.cstr(), "") == 0); + ASL_TEST_ASSERT(strcmp(sink.cstr(), "") == 0); sink.reset(); asl::format(&sink, "Hello, {}!", "world"); - assert(strcmp(sink.cstr(), "Hello, world!") == 0); + ASL_TEST_ASSERT(strcmp(sink.cstr(), "Hello, world!") == 0); sink.reset(); asl::format(&sink, "Hello, {}! {}", "world"); - assert(strcmp(sink.cstr(), "Hello, world! ") == 0); + ASL_TEST_ASSERT(strcmp(sink.cstr(), "Hello, world! ") == 0); sink.reset(); asl::format(&sink, "Hello, pup!", "world"); - assert(strcmp(sink.cstr(), "Hello, pup!") == 0); + ASL_TEST_ASSERT(strcmp(sink.cstr(), "Hello, pup!") == 0); sink.reset(); asl::format(&sink, "{}", "CHEESE"); - assert(strcmp(sink.cstr(), "CHEESE") == 0); + ASL_TEST_ASSERT(strcmp(sink.cstr(), "CHEESE") == 0); sink.reset(); asl::format(&sink, "{ ", "CHEESE"); - assert(strcmp(sink.cstr(), " ") == 0); + ASL_TEST_ASSERT(strcmp(sink.cstr(), " ") == 0); sink.reset(); asl::format(&sink, "{", "CHEESE"); - assert(strcmp(sink.cstr(), "") == 0); + ASL_TEST_ASSERT(strcmp(sink.cstr(), "") == 0); sink.reset(); asl::format(&sink, "a{{b"); - assert(strcmp(sink.cstr(), "a{b") == 0); + ASL_TEST_ASSERT(strcmp(sink.cstr(), "a{b") == 0); sink.reset(); asl::format(&sink, "{{{}}} }", "CHEESE"); - assert(strcmp(sink.cstr(), "{CHEESE} }") == 0); + ASL_TEST_ASSERT(strcmp(sink.cstr(), "{CHEESE} }") == 0); sink.reset(); asl::format(&sink, "{} {} {}", 0, 1, 2); - assert(strcmp(sink.cstr(), "0 1 2") == 0); + ASL_TEST_ASSERT(strcmp(sink.cstr(), "0 1 2") == 0); sink.reset(); asl::format(&sink, "{} {} {}", 10, 11, 12); - assert(strcmp(sink.cstr(), "10 11 12") == 0); + ASL_TEST_ASSERT(strcmp(sink.cstr(), "10 11 12") == 0); sink.reset(); asl::format(&sink, "{} {} {}", 100, 101, 102); - assert(strcmp(sink.cstr(), "100 101 102") == 0); + ASL_TEST_ASSERT(strcmp(sink.cstr(), "100 101 102") == 0); sink.reset(); asl::format(&sink, "{} {} {}", 1000, 1001, 1002); - assert(strcmp(sink.cstr(), "1000 1001 1002") == 0); + ASL_TEST_ASSERT(strcmp(sink.cstr(), "1000 1001 1002") == 0); sink.reset(); asl::format(&sink, "{} {} {} {}", -1, -23, -456, -7890); - assert(strcmp(sink.cstr(), "-1 -23 -456 -7890") == 0); + ASL_TEST_ASSERT(strcmp(sink.cstr(), "-1 -23 -456 -7890") == 0); sink.reset(); asl::format(&sink, "{} {}", true, false); - assert(strcmp(sink.cstr(), "true false") == 0); - - return 0; + ASL_TEST_ASSERT(strcmp(sink.cstr(), "true false") == 0); } -- cgit