aboutsummaryrefslogtreecommitdiffhomepage
path: root/libslang/src/test/bstring.sl
blob: 3ac8a3d7a4c69fd38e54586831837dae3dec7a7c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
_debug_info = 1; () = evalfile ("inc.sl");

print ("Testing Binary Strings...");

variable a = "\000A\000B\000C\000D";

if (typeof (a) != BString_Type) failed ("typeof");

if (bstrlen (a) != 8) failed ("bstrlen");

if ((a[[0:7:2]] != "\000\000\000\000")
    or (a[[1:7:2]] != "ABCD")) failed ("array indexing");

if (strlen (a) != 0) failed ("typecast");

a += "XYZ";

if (a[[8:]] != "XYZ") failed ("+= op");

a = "XYZ" + a;
if (a == "XYZ") failed ("== op");

if (strcmp (a, "XYZ")) failed ("failed strcmp");

loop (1000)
{
   a = "\000A\000B\000C\000D";
   a = "A\000B\000C\000";
}

print ("Ok\n");
exit (0);