Author: aschnell
Date: Thu Nov 20 15:30:42 2008
New Revision: 53484
URL: http://svn.opensuse.org/viewcvs/yast?rev=53484&view=rev
Log:
- added some test-cases
Added:
trunk/storage/libstorage/testsuite/humanstring1.cc
trunk/storage/libstorage/testsuite/humanstring2.cc
trunk/storage/libstorage/testsuite/single.out/humanstring1.err
trunk/storage/libstorage/testsuite/single.out/humanstring1.out
trunk/storage/libstorage/testsuite/single.out/humanstring2.err
trunk/storage/libstorage/testsuite/single.out/humanstring2.out
Modified:
trunk/storage/libstorage/testsuite/Makefile.am
Modified: trunk/storage/libstorage/testsuite/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/testsuite/Makefile.am?rev=53484&r1=53483&r2=53484&view=diff
==============================================================================
--- trunk/storage/libstorage/testsuite/Makefile.am (original)
+++ trunk/storage/libstorage/testsuite/Makefile.am Thu Nov 20 15:30:42 2008
@@ -11,7 +11,9 @@
AM_CPPFLAGS =
AM_CXXFLAGS =
-noinst_PROGRAMS = partition1.single format1.single uuid1.single fstab1.single lvm_create.single lvm_extend.single md_create.single
+noinst_PROGRAMS = partition1.single format1.single uuid1.single fstab1.single \
+ lvm_create.single lvm_extend.single md_create.single \
+ humanstring1.single humanstring2.single
partition1_single_SOURCES = partition1.cc
partition1_single_LDADD = ../src/liby2storage.la
@@ -34,5 +36,11 @@
md_create_single_SOURCES = md_create.cc
md_create_single_LDADD = ../src/liby2storage.la
+humanstring1_single_SOURCES = humanstring1.cc
+humanstring1_single_LDADD = ../src/liby2storage.la
+
+humanstring2_single_SOURCES = humanstring2.cc
+humanstring2_single_LDADD = ../src/liby2storage.la
+
clean-local:
rm -f tmp.err.* tmp.out.* site.exp site.bak
Added: trunk/storage/libstorage/testsuite/humanstring1.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/testsuite/humanstring1.cc?rev=53484&view=auto
==============================================================================
--- trunk/storage/libstorage/testsuite/humanstring1.cc (added)
+++ trunk/storage/libstorage/testsuite/humanstring1.cc Thu Nov 20 15:30:42 2008
@@ -0,0 +1,42 @@
+
+#include <iostream>
+#include <locale>
+
+#include
+
+using namespace std;
+using namespace storage;
+
+
+// Don't bother setting up locale for gettext since we don't have translations
+// during package build.
+
+
+StorageInterface* s = 0;
+
+
+void
+test(const char* loc, unsigned long long size, bool classic,
+ int precision, bool omit_zeroes)
+{
+ locale::global(locale(loc));
+ cout << s->byteToHumanString(size, classic, precision, omit_zeroes) << endl;
+}
+
+
+int
+main()
+{
+ s = createStorageInterface(true, true, false);
+
+ test("en_GB.UTF-8", 1024, true, 2, true);
+ test("en_GB.UTF-8", 1024, true, 2, false);
+
+ test("de_DE.UTF-8", 123456789, true, 4, false);
+ test("de_DE.UTF-8", 123456789, false, 4, false);
+
+ test("fr_FR.UTF-8", 123456789, true, 4, false);
+ test("fr_FR.UTF-8", 123456789, false, 4, false);
+
+ delete s;
+}
Added: trunk/storage/libstorage/testsuite/humanstring2.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/testsuite/humanstring2.cc?rev=53484&view=auto
==============================================================================
--- trunk/storage/libstorage/testsuite/humanstring2.cc (added)
+++ trunk/storage/libstorage/testsuite/humanstring2.cc Thu Nov 20 15:30:42 2008
@@ -0,0 +1,62 @@
+
+#include <iostream>
+#include <locale>
+
+#include
+
+using namespace std;
+using namespace storage;
+
+
+// Don't bother setting up locale for gettext since we don't have translations
+// during package build.
+
+
+StorageInterface* s = 0;
+
+
+void
+test(const char* loc, const char* str, bool classic)
+{
+ locale::global(locale(loc));
+
+ unsigned long long size = 0;
+
+ if (s->humanStringToByte(str, classic, size))
+ cout << "parse ok " << size << endl;
+ else
+ cout << "parse error" << endl;
+}
+
+
+int
+main()
+{
+ s = createStorageInterface(true, true, false);
+
+ test("en_GB.UTF-8", "42", true);
+ test("en_GB.UTF-8", "42B", true);
+ test("en_GB.UTF-8", "42 B", true);
+
+ test("en_GB.UTF-8", "42", false);
+ test("en_GB.UTF-8", "42B", false);
+ test("en_GB.UTF-8", "42 B", false);
+
+ test("en_GB.UTF-8", "12.4GB", true);
+ test("en_GB.UTF-8", "12.4 GB", true);
+
+ test("en_GB.UTF-8", "12.4GB", false);
+ test("en_GB.UTF-8", "12.4 gb", false);
+ test("en_GB.UTF-8", "12.4g", false);
+ test("en_GB.UTF-8", "12.4 G", false);
+
+ test("en_GB.UTF-8", "123,456.789kB", false);
+ test("de_DE.UTF-8", "123.456,789kB", false);
+ test("fr_FR.UTF-8", "123 456,789kB", false);
+
+ test("en_GB.UTF-8", "123,456.789 kB", false);
+ test("de_DE.UTF-8", "123.456,789 kB", false);
+ test("fr_FR.UTF-8", "123 456,789 kB", false);
+
+ delete s;
+}
Added: trunk/storage/libstorage/testsuite/single.out/humanstring1.err
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/testsuite/single.out/humanstring1.err?rev=53484&view=auto
==============================================================================
(empty)
Added: trunk/storage/libstorage/testsuite/single.out/humanstring1.out
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/testsuite/single.out/humanstring1.out?rev=53484&view=auto
==============================================================================
--- trunk/storage/libstorage/testsuite/single.out/humanstring1.out (added)
+++ trunk/storage/libstorage/testsuite/single.out/humanstring1.out Thu Nov 20 15:30:42 2008
@@ -0,0 +1,6 @@
+1 kB
+1.00 kB
+117.7376 MB
+117,7376 MB
+117.7376 MB
+117,7376 MB
Added: trunk/storage/libstorage/testsuite/single.out/humanstring2.err
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/testsuite/single.out/humanstring2.err?rev=53484&view=auto
==============================================================================
(empty)
Added: trunk/storage/libstorage/testsuite/single.out/humanstring2.out
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/testsuite/single.out/humanstring2.out?rev=53484&view=auto
==============================================================================
--- trunk/storage/libstorage/testsuite/single.out/humanstring2.out (added)
+++ trunk/storage/libstorage/testsuite/single.out/humanstring2.out Thu Nov 20 15:30:42 2008
@@ -0,0 +1,18 @@
+parse error
+parse ok 42
+parse ok 42
+parse ok 42
+parse ok 42
+parse ok 42
+parse ok 13314398617
+parse ok 13314398617
+parse ok 13314398617
+parse ok 13314398617
+parse ok 13314398617
+parse ok 13314398617
+parse ok 126419751
+parse ok 126419751
+parse ok 126419751
+parse ok 126419751
+parse ok 126419751
+parse ok 126419751
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org