use --WORLD as root of all actions (GC just deletes --WORLD)
[mala.git] / tests / test-mala_strings.c
blob3a7f237e8d35c5a1d8ce949e3d6497cb5bab64a7
1 /*
2 * Copyright (C) 2004, Christian Thaeter <chth@gmx.net>
4 * This file is part of the MaLa extension Language.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, contact me.
19 #include <stdio.h>
20 #include <stdlib.h>
22 #define MALA_GLIBC /*TODO remove*/
23 #include "../engine/strings.h"
25 #define TEST(t) printf("TEST %s: ",#t);\
26 fflush(stdout);\
27 if((t))printf(".. OK\n");\
28 else printf(".. FAILED\n")
30 #define TEST_VOID(t) printf("TEST %s: ",#t);\
31 fflush(stdout); t; printf(".. OK\n")
34 void
35 basic_construction()
37 MalaStringBucket test = MALA_STRINGBUCKET_STATIC (MALA_STRING_FWD,0);
39 MalaString a,b,c,d;
41 TEST(a = mala_string_new ("bar", test));
42 TEST(b = mala_string_new ("baz", test));
43 TEST(c = mala_string_new ("bar", test));
44 TEST(d = mala_string_new ("bar", NULL));
45 TEST_VOID(mala_stringbucket_erase (test));
46 TEST_VOID(mala_string_free (d));
49 void
50 conversion()
52 //MalaStringBucket test = MALA_STRINGBUCKET_STATIC (MALA_STRING_FWD,0);
54 MalaString a; //,b,c,d;
56 MalaString onetwothreefour = MALA_STRING_STATIC("1234");
58 TEST(a = mala_string_new_print(NULL, "%d",1234));
59 TEST(mala_string_compare (a, onetwothreefour) == 0);
60 TEST(mala_string_length (a) == 4);
62 mala_string_free (a);
69 int main()
71 basic_construction();
72 conversion();
73 exit(0);
78 // arch-tag: 99da2844-99b2-4ec3-81ed-32db697656ec