updated test.sh for nobug compatibility, has still problems with joined stderr and...
[mala.git] / tests / test-mala_stringlists.c
blob31b9636f55eda62b15c6b7c8f8345caf46350616
1 /*
2 * test-mala_stringlists.c
4 * Copyright (C) 2004, Christian Thaeter <chth@gmx.net>
6 * This file is part of the MaLa extension Language.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, contact me.
21 #include <stdio.h>
22 #include <stdlib.h>
23 #include <nobug.h>
24 #include <acogc.h>
26 #include "../engine/strings.h"
27 #include "../engine/stringbucket.h"
28 #include "../engine/stringlist.h"
30 #define TEST(t) printf("TEST %s: ",#t);\
31 if((t))printf(".. OK\n");\
32 else printf(".. FAILED\n")
34 #define TEST_VOID(t) printf("TEST %s: ",#t);\
35 fflush(stdout); t; printf(".. OK\n")
38 void
39 runtest (MalaEngine engine)
41 ACOGC_STACK_ENTER (&engine->gcroot);
42 ACOGC_STACK_PTR (MalaStringList, a);
43 ACOGC_STACK_PTR (MalaStringList, b);
44 ACOGC_STACK_PTR (MalaStringList, c);
47 TEST (a.ptr = mala_stringlist_new (engine));
48 TEST (b.ptr = mala_stringlist_new (engine));
50 char* testarray[] = {"foo", "bar", "baz", NULL};
52 mala_stringlist_dump (a.ptr, stdout, "empty list..\n", " %d: ", "%s\n", "", " ..OK\n\n");
54 mala_stringlist_append_cstrs (a.ptr, -1, testarray, engine);
56 mala_stringlist_dump (a.ptr, stdout, "append cstrs..\n", " %d: ","%s\n", "", " ..OK\n\n");
58 ACOGC_STACK_LEAVE;
61 int main()
63 MalaEngine engine = mala_engine_new ();
65 runtest (engine);
67 mala_engine_free (engine);
68 exit(0);
72 // arch-tag: 9c80a752-81ef-47f3-8536-05e15605b639