diff options
author | Steven Le Rouzic <steven.lerouzic@gmail.com> | 2024-10-28 23:52:48 +0100 |
---|---|---|
committer | Steven Le Rouzic <steven.lerouzic@gmail.com> | 2024-12-20 15:35:58 +0100 |
commit | 2a10eaae094e48a157d55ec886aaa07b0d0be6c9 (patch) | |
tree | e334ce5d2de1604eb168a3269be887bbc078df70 /asl/tests/format_tests.cpp | |
parent | 46cc6bfc5f62bb45427ef7778ba5fc04d7a546da (diff) |
Some work on test framework & option
Diffstat (limited to 'asl/tests/format_tests.cpp')
-rw-r--r-- | asl/tests/format_tests.cpp | 40 |
1 files changed, 20 insertions, 20 deletions
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 <cstdlib>
#include <cstring>
@@ -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! <ERROR>") == 0);
+ ASL_TEST_ASSERT(strcmp(sink.cstr(), "Hello, world! <ERROR>") == 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(), "<ERROR> ") == 0);
+ ASL_TEST_ASSERT(strcmp(sink.cstr(), "<ERROR> ") == 0);
sink.reset();
asl::format(&sink, "{", "CHEESE");
- assert(strcmp(sink.cstr(), "<ERROR>") == 0);
+ ASL_TEST_ASSERT(strcmp(sink.cstr(), "<ERROR>") == 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);
}
|