Skip to content

Commit

Permalink
test: update test(used new test macros)
Browse files Browse the repository at this point in the history
  • Loading branch information
molingyu committed Sep 7, 2024
1 parent 6fff6bb commit 262dc7a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 17 deletions.
2 changes: 2 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# i18n-format unit test app

add_executable(test
unit_test.h
unit_test.c
main.c
test_word2number.c
)
Expand Down
12 changes: 3 additions & 9 deletions test/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 ); } );
}
23 changes: 15 additions & 8 deletions test/test_word2number.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit 262dc7a

Please sign in to comment.