Author: aschnell Date: Tue Apr 1 21:14:28 2008 New Revision: 45944 URL: http://svn.opensuse.org/viewcvs/yast?rev=45944&view=rev Log: - let String::FormatSizeWithPrecision return "1 MB" instead of "1024 kB" and alike Modified: trunk/yast2/library/types/src/String.ycp trunk/yast2/library/types/testsuite/tests/String.out trunk/yast2/library/types/testsuite/tests/String.ycp trunk/yast2/package/yast2.changes Modified: trunk/yast2/library/types/src/String.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/yast2/library/types/src/String.yc... ============================================================================== --- trunk/yast2/library/types/src/String.ycp (original) +++ trunk/yast2/library/types/src/String.ycp Tue Apr 1 21:14:28 2008 @@ -79,7 +79,7 @@ * Return a pretty description of a byte count * * Return a pretty description of a byte count with required precision - * and using KB, MB or GB as unit as appropriate. + * and using kB, MB, GB or TB as unit as appropriate. * * @param bytes size (e.g. free diskspace, memory size) in Bytes * @param precision number of fraction digits in output @@ -87,8 +87,9 @@ * (usefull for memory size - 128 MB RAM looks better than 128.00 MB RAM) * @return formatted string * - * @example FormatSizeWithPrecision(4096, 2, true) -> "4 KB" - * @example FormatSizeWithPrecision(4096, 2, false) -> "4.00 KB" + * @example FormatSizeWithPrecision(4096, 2, true) -> "4 kB" + * @example FormatSizeWithPrecision(4096, 2, false) -> "4.00 kB" + * @example FormatSizeWithPrecision(1024*1024, 2, true) -> "1 MB" */ global define string FormatSizeWithPrecision(integer bytes, integer precision, boolean omit_zeroes) ``{ @@ -108,7 +109,7 @@ integer index = 0; float whole = tofloat(bytes); - while((whole > 1024.0 || whole < -1024.0) && index < size(units)) { + while((whole >= 1024.0 || whole <= -1024.0) && index < size(units)) { whole = whole / 1024.0; unit = units[index]:""; index = index + 1; Modified: trunk/yast2/library/types/testsuite/tests/String.out URL: http://svn.opensuse.org/viewcvs/yast/trunk/yast2/library/types/testsuite/tes... ============================================================================== --- trunk/yast2/library/types/testsuite/tests/String.out (original) +++ trunk/yast2/library/types/testsuite/tests/String.out Tue Apr 1 21:14:28 2008 @@ -24,7 +24,9 @@ Return 0 Return 1.00 Return 1.001 kB +Return 1 MB Return 1.00 MB +Return 1 GB Return 1.000 GB Return 1.00 TB Return 1024.1 TB Modified: trunk/yast2/library/types/testsuite/tests/String.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/yast2/library/types/testsuite/tes... ============================================================================== --- trunk/yast2/library/types/testsuite/tests/String.ycp (original) +++ trunk/yast2/library/types/testsuite/tests/String.ycp Tue Apr 1 21:14:28 2008 @@ -32,7 +32,9 @@ TEST(``(String::FormatSizeWithPrecision(0, nil, true)), [], nil); TEST(``(String::FormatSizeWithPrecision(1, 2, false)), [], nil); TEST(``(String::FormatSizeWithPrecision(1025, 3, false)), [], nil); +TEST(``(String::FormatSizeWithPrecision(1024*1024, 2, true)), [], nil); TEST(``(String::FormatSizeWithPrecision(1049000, 2, true)), [], nil); +TEST(``(String::FormatSizeWithPrecision(1024*1024*1024, 2, true)), [], nil); TEST(``(String::FormatSizeWithPrecision(1074000000, 3, false)), [], nil); TEST(``(String::FormatSizeWithPrecision(1100000000000, 2, false)), [], nil); TEST(``(String::FormatSizeWithPrecision(1126000000000000, 1, true)), [], nil); Modified: trunk/yast2/package/yast2.changes URL: http://svn.opensuse.org/viewcvs/yast/trunk/yast2/package/yast2.changes?rev=4... ============================================================================== --- trunk/yast2/package/yast2.changes (original) +++ trunk/yast2/package/yast2.changes Tue Apr 1 21:14:28 2008 @@ -1,4 +1,10 @@ ------------------------------------------------------------------- +Tue Apr 01 20:49:22 CEST 2008 - aschnell@suse.de + +- let String::FormatSizeWithPrecision return "1 MB" instead of + "1024 kB" and alike + +------------------------------------------------------------------- Tue Apr 1 09:46:44 CEST 2008 - jsrain@suse.cz - merged texts from proofread -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org