Mercurial > hg > th-libs
comparison tests.c @ 524:19dc326dcdad
Add few tests for th_get_hex_triplet().
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Fri, 27 Dec 2019 09:16:21 +0200 |
parents | 9acbbfea68a9 |
children | 59b8f15c5334 |
comparison
equal
deleted
inserted
replaced
523:9acbbfea68a9 | 524:19dc326dcdad |
---|---|
283 } | 283 } |
284 | 284 |
285 | 285 |
286 #define NCOUNT(xxx) (sizeof(xxx) / sizeof(xxx[0])) | 286 #define NCOUNT(xxx) (sizeof(xxx) / sizeof(xxx[0])) |
287 | 287 |
288 | |
289 #define TEST1(fun) do { \ | |
290 test_ctx ctx; \ | |
291 test_start(&ctx, # fun ); \ | |
292 test_result(&ctx, fun); \ | |
293 test_end(&ctx); \ | |
294 } while (0) | |
295 | |
296 #define TEST1A(fmt, fun, fcmp, fres) do { \ | |
297 test_ctx ctx; \ | |
298 test_start(&ctx, #fun " " #fcmp " " fmt " (" fmt ")", fres, fun); \ | |
299 test_result(&ctx, fun fcmp fres ); \ | |
300 test_end(&ctx); \ | |
301 } while (0) | |
288 | 302 |
289 #define TEST2(fun, str1, str2, ret) do { \ | 303 #define TEST2(fun, str1, str2, ret) do { \ |
290 test_ctx ctx; \ | 304 test_ctx ctx; \ |
291 test_start(&ctx, # fun "('%s', '%s')", str1, str2); \ | 305 test_start(&ctx, # fun "('%s', '%s')", str1, str2); \ |
292 test_result(&ctx, ( fun (str1, str2) == 0) == ret); \ | 306 test_result(&ctx, ( fun (str1, str2) == 0) == ret); \ |
737 { | 751 { |
738 test_config(); | 752 test_config(); |
739 } | 753 } |
740 | 754 |
741 // | 755 // |
756 // String functions | |
757 // | |
758 if (test_set_start("String functions")) | |
759 { | |
760 char *tmpStr; | |
761 unsigned int tmpUint; | |
762 | |
763 TEST1(th_get_hex_triplet("0fac11", &tmpUint) == TRUE); | |
764 TEST1A("0x%06x", tmpUint, ==, 0x0fac11); | |
765 TEST1(th_get_hex_triplet("120fac11", &tmpUint) == TRUE); | |
766 TEST1A("0x%06x", tmpUint, ==, 0x120fac11); | |
767 TEST1(th_get_hex_triplet("x120fac11", &tmpUint) == FALSE); | |
768 } | |
769 | |
770 // | |
742 // Print summary and exit | 771 // Print summary and exit |
743 // | 772 // |
744 tprint(1, | 773 tprint(1, |
745 "======================================================\n"); | 774 "======================================================\n"); |
746 | 775 |