CPPUNIT_TEST( TestStrip );
CPPUNIT_TEST( TestNormalize );
CPPUNIT_TEST( TestReplace );
+ CPPUNIT_TEST( TestGetHumanReadable );
#ifdef __WINDOWS__
CPPUNIT_TEST( TestShortLongPath );
#endif // __WINDOWS__
void TestStrip();
void TestNormalize();
void TestReplace();
+ void TestGetHumanReadable();
#ifdef __WINDOWS__
void TestShortLongPath();
#endif // __WINDOWS__
fn.GetFullPath(wxPATH_UNIX) );
}
+void FileNameTestCase::TestGetHumanReadable()
+{
+ static const struct TestData
+ {
+ const char *result;
+ int size;
+ int prec;
+ wxSizeConvention conv;
+ } testData[] =
+ {
+ { "NA", 0, 1, wxSIZE_CONV_TRADITIONAL },
+ { "2.0 KB", 2000, 1, wxSIZE_CONV_TRADITIONAL },
+ { "1.953 KiB", 2000, 3, wxSIZE_CONV_IEC },
+ { "2.000 KB", 2000, 3, wxSIZE_CONV_SI },
+ { "297 KB", 304351, 0, wxSIZE_CONV_TRADITIONAL },
+ { "304 KB", 304351, 0, wxSIZE_CONV_SI },
+ };
+
+ for ( unsigned n = 0; n < WXSIZEOF(testData); n++ )
+ {
+ const TestData& td = testData[n];
+
+ CPPUNIT_ASSERT_EQUAL
+ (
+ td.result,
+ wxFileName::GetHumanReadableSize(td.size, "NA", td.prec, td.conv)
+ );
+ }
+
+ // also test the default convention value
+ CPPUNIT_ASSERT_EQUAL( "1.4 MB", wxFileName::GetHumanReadableSize(1512993, "") );
+}
+
void FileNameTestCase::TestStrip()
{
CPPUNIT_ASSERT_EQUAL( "", wxFileName::StripExtension("") );