diff options
author | 2012-02-29 11:27:14 -0800 | |
---|---|---|
committer | 2012-02-29 16:14:51 -0800 | |
commit | 8ada404c5f1ec068a8bad144b63878d9962aa1f0 (patch) | |
tree | 6964537047cec6e4b09d0744a01c3208b26dbfea /fish_tests.cpp | |
parent | ebba30d67157cf0dee46edfa5f47a216b1f35ae6 (diff) |
More work towards improving relationship between multithreading and fork
Diffstat (limited to 'fish_tests.cpp')
-rw-r--r-- | fish_tests.cpp | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/fish_tests.cpp b/fish_tests.cpp index c8f72e75..418d0983 100644 --- a/fish_tests.cpp +++ b/fish_tests.cpp @@ -147,10 +147,32 @@ static void test_escape() free( (void *)e ); free( (void *)u ); - } - + } +} - +static void test_format(void) { + say( L"Testing formatting functions" ); + struct { unsigned long long val; const char *expected; } tests[] = { + { 0, "empty" }, + { 1, "1B" }, + { 2, "2B" }, + { 1024, "1kB" }, + { 1870, "1.8kB" }, + { 4322911, "4.1MB" } + }; + size_t i; + for (i=0; i < sizeof tests / sizeof *tests; i++) { + char buff[128]; + format_size_safe(buff, tests[i].val); + assert( ! strcmp(buff, tests[i].expected)); + } + + for (int j=-129; j <= 129; j++) { + char buff1[128], buff2[128]; + format_int_safe(buff1, j); + sprintf(buff2, "%d", j); + assert( ! strcmp(buff1, buff2)); + } } /** @@ -698,6 +720,7 @@ int main( int argc, char **argv ) reader_init(); env_init(); + test_format(); test_escape(); test_convert(); test_tok(); |