2 #include <Sylph/Core/String.h>
18 Array<uchar> a = s.utf16();
19 CPPUNIT_ASSERT(a[0] == 'f');
20 CPPUNIT_ASSERT(a[1] == 'o');
21 CPPUNIT_ASSERT(a[2] == 'o');
22 CPPUNIT_ASSERT(a[3] == 'b');
23 CPPUNIT_ASSERT(a[4] == 'a');
24 CPPUNIT_ASSERT(a[5] == 'r');
28 String s = "éèçàŒù£";
29 Array<uchar> a = s.utf16();
30 CPPUNIT_ASSERT(a[0] == 0x00E9);
31 CPPUNIT_ASSERT(a[1] == 0x00E8);
32 CPPUNIT_ASSERT(a[2] == 0x00E7);
33 CPPUNIT_ASSERT(a[3] == 0x00E0);
34 CPPUNIT_ASSERT(a[4] == 0x008C);
35 CPPUNIT_ASSERT(a[5] == 0x00F9);
36 CPPUNIT_ASSERT(a[6] == 0x00A3);
37 CPPUNIT_ASSERT(a[7] == 0xF8FF);
44 CPPUNIT_ASSERT(s == t);
45 CPPUNIT_ASSERT(t == s);
46 CPPUNIT_ASSERT(s != u);
47 CPPUNIT_ASSERT(u != s);
48 CPPUNIT_ASSERT(t != u);
49 CPPUNIT_ASSERT(u != t);
52 @testUnicodeRealEquality:
53 String s = "éèçàŒù£";
54 String t = "éèçàŒù£";
55 String u = "Œù£éèçà";
56 CPPUNIT_ASSERT(s == t);
57 CPPUNIT_ASSERT(t == s);
58 CPPUNIT_ASSERT(s != u);
59 CPPUNIT_ASSERT(u != s);
60 CPPUNIT_ASSERT(t != u);
61 CPPUNIT_ASSERT(u != t);
67 CPPUNIT_ASSERT(s == t);
68 CPPUNIT_ASSERT(t == s);
71 @testUnicodeCopyEquality:
72 String s = "éèçàŒù£";
74 CPPUNIT_ASSERT(s == t);
75 CPPUNIT_ASSERT(t == s);
78 @testRefcountEquality:
81 CPPUNIT_ASSERT(s == t);
82 CPPUNIT_ASSERT(t == s);
87 CPPUNIT_ASSERT(s == s);
90 @testUnicodeSelfEquality:
91 String s = "éèçàŒù£";
92 CPPUNIT_ASSERT(s == s);
97 CPPUNIT_ASSERT(s == "true");
99 CPPUNIT_ASSERT(t == "false");
104 CPPUNIT_ASSERT(s == "12345678");
105 String t = 12345678901234LL;
106 CPPUNIT_ASSERT(t == "12345678901234");
109 @testFloatConstructor:
111 CPPUNIT_ASSERT(s == "3.14");
113 CPPUNIT_ASSERT(t == "3.14");
118 CPPUNIT_ASSERT(s.length() == 6);
119 String t = "éèçàŒù£";
120 CPPUNIT_ASSERT(t.length() == 8);
125 CPPUNIT_ASSERT(s.at(0) == 'f');
126 CPPUNIT_ASSERT(s.at(1) == 'o');
127 CPPUNIT_ASSERT(s.at(2) == 'o');
128 CPPUNIT_ASSERT(s.at(3) == 'b');
129 CPPUNIT_ASSERT(s.at(4) == 'a');
130 CPPUNIT_ASSERT(s.at(5) == 'r');
134 String s = "éèçàŒù£";
135 CPPUNIT_ASSERT(s.at(0) == 0x00E9);
136 CPPUNIT_ASSERT(s.at(1) == 0x00E8);
137 CPPUNIT_ASSERT(s.at(2) == 0x00E7);
138 CPPUNIT_ASSERT(s.at(3) == 0x00E0);
139 CPPUNIT_ASSERT(s.at(4) == 0x008C);
140 CPPUNIT_ASSERT(s.at(5) == 0x00F9);
141 CPPUNIT_ASSERT(s.at(6) == 0x00A3);
142 CPPUNIT_ASSERT(s.at(7) == 0xF8FF);
151 @testAstralPlaneUnicode:
159 const char * c = s.ascii();
160 CPPUNIT_ASSERT(std::strcmp(c,"foobar") == 0);
161 String t = "français";
162 const char * c2 = t.ascii();
163 CPPUNIT_ASSERT(std::strcmp(c,"fran?ais") == 0);
168 const char * c = s.utf8();
169 CPPUNIT_ASSERT(std::strcmp(c,"foobar") == 0);
170 String t = "français";
171 const char * c2 = t.utf8();
172 CPPUNIT_ASSERT(std::strcmp(c,"français") == 0);
177 CPPUNIT_ASSERT(s.toLowerCase() == "foo");
179 CPPUNIT_ASSERT(s.toLowerCase() == "foo");
181 CPPUNIT_ASSERT(!(s.toLowerCase() == "foo"));
186 CPPUNIT_ASSERT(s.toUpperCase() == "FOO");
188 CPPUNIT_ASSERT(s.toUpperCase() == "FOO");
190 CPPUNIT_ASSERT(!(s.toUpperCase() == "foo"));
193 @testEqualsIgnoreCase:
196 CPPUNIT_ASSERT(s.equalsIgnoreCase(s));
197 CPPUNIT_ASSERT(s.equalsIgnoreCase(t));
198 CPPUNIT_ASSERT(t.equalsIgnoreCase(t));
199 CPPUNIT_ASSERT(t.equalsIgnoreCase(s));
200 CPPUNIT_ASSERT(!s.equalsIgnoreCase("Fox"));
201 CPPUNIT_ASSERT(!t.equalsIgnoreCase("Fox"));
224 CPPUNIT_ASSERT(s.boolValue());
226 CPPUNIT_ASSERT(s.boolValue());
228 CPPUNIT_ASSERT(!s.boolValue());
230 CPPUNIT_ASSERT(!s.boolValue());
232 CPPUNIT_ASSERT(!s.boolValue());
234 CPPUNIT_ASSERT(!s.boolValue());
239 CPPUNIT_ASSERT(a.intValue() == 123);
241 CPPUNIT_ASSERT(b.intValue() == -123);
243 CPPUNIT_ASSERT(c.intValue() == 333);
245 CPPUNIT_ASSERT(d.intValue() == 0);
256 CPPUNIT_ASSERT(a == "foobar");
257 CPPUNIT_ASSERT(c == "foobar");
263 CPPUNIT_ASSERT(t == "-----");
267 CPPUNIT_ASSERT(v == "ééééé");