From b948c321fe833e399b9d33f042818f104d0fe47f Mon Sep 17 00:00:00 2001 From: molingyu Date: Sun, 8 Sep 2024 02:32:20 +0800 Subject: [PATCH] test: update test --- test/test_word2number.c | 2 +- test/unit_test.h | 19 ++++++++++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/test/test_word2number.c b/test/test_word2number.c index aa4c2dc..e51e656 100644 --- a/test/test_word2number.c +++ b/test/test_word2number.c @@ -180,7 +180,7 @@ int Word2NumberTest( void ) EXPECT_EQUAL( word2number( u8"一亿二千三百四十五万六千七百八十九", "zh_CN" ), 123456789 ); } ); - UT_IT( "should be true", { EXPECT_TRUE( validate_word( u8"万万", "zh_CN" ) ); + UT_IT( "should be false", { EXPECT_FALSE( validate_word( u8"万万", "zh_CN" ) ); }); }); UNIT_END diff --git a/test/unit_test.h b/test/unit_test.h index a1eb371..7a61cc9 100644 --- a/test/unit_test.h +++ b/test/unit_test.h @@ -212,9 +212,6 @@ extern int _utest_test_unit_return; } \ while ( 0 ) -#define UNIT_START printf( "Runs: %s\n", __FILE__ ); -#define UNIT_END return _utest_test_unit_return; - #define RUN_TEST( T ) \ do \ { \ @@ -233,6 +230,9 @@ extern int _utest_test_unit_return; } \ while ( 0 ) +#define UNIT_START printf( "Runs: %s\n", __FILE__ ); +#define UNIT_END return _utest_test_unit_return; + #define DESCRIBE( NAME, BLOCK ) \ do \ { \ @@ -276,6 +276,19 @@ extern int _utest_test_unit_return; } \ while ( 0 ) +#define EXPECT_FALSE( C ) \ + do \ + { \ + _utest_test_closure_total += 1; \ + if ( ( C ) != 0 ) \ + { \ + _utest_test_closure_failed += 1; \ + printf( "\033[31m %s(%d): '" #C "' not true.\033[0m\n", __FILE__, __LINE__ ); \ + } \ + _utest_test_closure_passed += 1; \ + } \ + while ( 0 ) + #define EXPECT_EQUAL( A, B ) \ do \ { \