From 262dc7ac721404e8894bab3d8379284114c109d9 Mon Sep 17 00:00:00 2001 From: molingyu Date: Sun, 8 Sep 2024 02:29:40 +0800 Subject: [PATCH] test: update test(used new test macros) --- test/CMakeLists.txt | 2 ++ test/main.c | 12 +++--------- test/test_word2number.c | 23 +++++++++++++++-------- 3 files changed, 20 insertions(+), 17 deletions(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index ce9d48f..5c18efb 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,6 +1,8 @@ # i18n-format unit test app add_executable(test + unit_test.h + unit_test.c main.c test_word2number.c ) diff --git a/test/main.c b/test/main.c index 68bc60c..420af87 100644 --- a/test/main.c +++ b/test/main.c @@ -164,18 +164,12 @@ // permanent authorization for you to choose that version for the // Library. -#include "test_macros.h" +#include "core.h" +#include "unit_test.h" extern int Word2NumberTest( void ); int main( void ) { - printf( "Starting i18n-format unit tests\n" ); - printf( "======================================\n" ); - RUN_TEST( Word2NumberTest ); - - printf( "======================================\n" ); - printf( "All i18n-format tests passed!\n" ); - - return 0; + TEST_START( "i18n-format", { RUN_TEST( Word2NumberTest ); } ); } diff --git a/test/test_word2number.c b/test/test_word2number.c index 2cb0f85..aa4c2dc 100644 --- a/test/test_word2number.c +++ b/test/test_word2number.c @@ -165,16 +165,23 @@ // Library. #include "core.h" -#include "test_macros.h" +#include "unit_test.h" #include "word2number.h" int Word2NumberTest( void ) { - ENSURE_EQUAL( word2number( u8"一", "zh_CN" ), 1 ); - ENSURE_EQUAL( word2number( u8"一千三百", "zh_CN" ), 1300 ); - ENSURE_EQUAL( word2number( u8"一千亿零五万", "zh_CN" ), 100000050000 ); - ENSURE_EQUAL( validate_word( u8"万万", "zh_CN" ), 0 ); - ENSURE_EQUAL( word2number( u8"亿零万", "zh_CN" ), 100010000 ); - ENSURE_EQUAL( word2number( u8"一亿二千三百四十五万六千七百八十九", "zh_CN" ), 123456789 ); - return 0; + UNIT_START + DESCRIBE( "word2number", { + UT_IT( "should be equal", { + EXPECT_EQUAL( word2number( u8"一", "zh_CN" ), 1 ); + EXPECT_EQUAL( word2number( u8"一千三百", "zh_CN" ), 1300 ); + EXPECT_EQUAL( word2number( u8"一千亿零五万", "zh_CN" ), 100000050000 ); + EXPECT_EQUAL( word2number( u8"亿零万", "zh_CN" ), 100010000 ); + EXPECT_EQUAL( word2number( u8"一亿二千三百四十五万六千七百八十九", "zh_CN" ), 123456789 ); + } ); + + UT_IT( "should be true", { EXPECT_TRUE( validate_word( u8"万万", "zh_CN" ) ); + }); + }); + UNIT_END } \ No newline at end of file