]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Improve string tests
authorJürg Billeter <j@bitron.ch>
Fri, 16 Jan 2009 09:50:16 +0000 (09:50 +0000)
committerJürg Billeter <juergbi@src.gnome.org>
Fri, 16 Jan 2009 09:50:16 +0000 (09:50 +0000)
2009-01-16  Jürg Billeter  <j@bitron.ch>

* tests/basic-types/strings.test:

Improve string tests

svn path=/trunk/; revision=2347

ChangeLog
tests/basic-types/strings.test

index 2397e39b9b4893b268ba2c81952e64895052db8c..c2c52fde7ecf8a3708594344c708d8bdf65135c6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2009-01-16  Jürg Billeter  <j@bitron.ch>
+
+       * tests/basic-types/strings.test:
+
+       Improve string tests
+
 2009-01-15  Jürg Billeter  <j@bitron.ch>
 
        * gobject/valadbusclientmodule.vala:
index 0ecd559b33572d8fe69bb3f4b7b2feff666ccdd9..246549ab5f0775326ab3109e36e9dc298bcc3ce7 100644 (file)
@@ -1,79 +1,37 @@
 
 Program: test
 
-using GLib;
-
-class Maman.Foo : Object {
-
-       const string[] array_field = {"1", "2"};
-
-       /* Does not work, because of bug 516287 
-       static const public string s1_field = "1" + "2";
-       static const string s2_field = "1" + "2";
-
-       */
-       static void test_string_initializers () {
-               /* Does not work yet. bug 530623
-               // Local constant
-               const string s1 = "1";
-               assert (s1 == "1");
-               */
-
-               /* Does not work yet. bug 530623 and bug 516287
-               // Local constant with string concatenation
-               const string s2 = "1" + "2";
-               assert (s2 == "12");
-               */
-
-               // string array
-               string[] array1 = {"1", "2"};
-               
-               assert (array1[0] == "1");
-               assert (array1[1] == "2");
-               assert (array1.length == 2);
-
-               // string array field
-               assert (array_field[0] == "1");
-               assert (array_field[1] == "2");
-               assert (array_field.length == 2);
-
-               /* Does not work, because of bug 516287 
-               // const field string with concatenation
-               assert (s1_field == "12");
-               assert (s2_field == "12");
-               */
-       }
-       static void test_string_operators () {
-               // string == operator compares content not reference
-               string s1 = "string";
-               string s2 = "string";
-               bool eq = (s1 == s2);
-               assert (eq);
-
-               // allow null string comparison
-               s1 = null;
-               s2 = null;
-               eq = (s1 == s2);
-               assert (eq);
-       }
-
-       static int main (string[] args) {
-               stdout.printf ("String Test: 1");
-
-               stdout.printf (" 2" + " 3");
-
-               string s = " 4";
-               s += " 5";
-               stdout.printf ("%s", s);
-
-               string t = " 5 6 7 8".substring (2, 4);
-               stdout.printf ("%s", t);
-
-               stdout.printf (" 8\n");
-
-               test_string_operators ();
-               test_string_initializers ();
+void test_string () {
+       // declaration and initialization
+       string s = "hello";
+       assert (s == "hello");
+
+       // assignment
+       s = "world";
+       assert (s == "world");
+
+       // access
+       string t = s;
+       assert (t == "world");
+
+       // +
+       s = "hello" + "world";
+       assert (s == "helloworld");
+
+       // equality and relational
+       s = "hello";
+       assert (s == "hello");
+       assert (s != "world");
+       assert (s < "i");
+       assert (!(s < "g"));
+       assert (s <= "hello");
+       assert (!(s <= "g"));
+       assert (s >= "hello");
+       assert (!(s >= "i"));
+       assert (s > "g");
+       assert (!(s > "i"));
+}
 
-               return 0;
-       }
+void main () {
+       test_string ();
 }