From 84a1b8aac8478428fdc8085400674be52278c6eb Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Tue, 3 Apr 2012 01:09:39 -0400 Subject: [PATCH] Improve test coverage Add tests for all the suffixes in g_format_size. --- glib/tests/fileutils.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/glib/tests/fileutils.c b/glib/tests/fileutils.c index 32f46a0..8816fd5 100644 --- a/glib/tests/fileutils.c +++ b/glib/tests/fileutils.c @@ -509,6 +509,17 @@ test_format_size_for_display (void) check_string (g_format_size (1000 * 1000), "1.0 MB"); check_string (g_format_size (1000 * 1000 * 1000), "1.0 GB"); + check_string (g_format_size_full (0, G_FORMAT_SIZE_IEC_UNITS), "0 bytes"); + check_string (g_format_size_full (1, G_FORMAT_SIZE_IEC_UNITS), "1 byte"); + check_string (g_format_size_full (2, G_FORMAT_SIZE_IEC_UNITS), "2 bytes"); + + check_string (g_format_size_full (2048ULL, G_FORMAT_SIZE_IEC_UNITS), "2.0 KiB"); + check_string (g_format_size_full (2048ULL * 1024, G_FORMAT_SIZE_IEC_UNITS), "2.0 MiB"); + check_string (g_format_size_full (2048ULL * 1024 * 1024, G_FORMAT_SIZE_IEC_UNITS), "2.0 GiB"); + check_string (g_format_size_full (2048ULL * 1024 * 1024 * 1024, G_FORMAT_SIZE_IEC_UNITS), "2.0 TiB"); + check_string (g_format_size_full (2048ULL * 1024 * 1024 * 1024 * 1024, G_FORMAT_SIZE_IEC_UNITS), "2.0 PiB"); + check_string (g_format_size_full (2048ULL * 1024 * 1024 * 1024 * 1024 * 1024, G_FORMAT_SIZE_IEC_UNITS), "2.0 EiB"); + check_string (g_format_size_full (238472938, G_FORMAT_SIZE_IEC_UNITS), "227.4 MiB"); check_string (g_format_size_full (238472938, G_FORMAT_SIZE_DEFAULT), "238.5 MB"); check_string (g_format_size_full (238472938, G_FORMAT_SIZE_LONG_FORMAT), "238.5 MB (238472938 bytes)"); -- 2.7.4