/[ascend]/trunk/ascend/compiler/test/test_symtab.c
ViewVC logotype

Contents of /trunk/ascend/compiler/test/test_symtab.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3369 - (show annotations) (download) (as text)
Sun May 27 00:44:12 2018 UTC (3 months, 3 weeks ago) by jpye
File MIME type: text/x-csrc
File size: 2759 byte(s)
symbol table test

1 /* ASCEND modelling environment
2 Copyright (C) 2007 Carnegie Mellon University
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2, or (at your option)
7 any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
16 *//**
17 @file
18 Unit test functions for compiler.
19 */
20 #include <ascend/compiler/symtab.h>
21 #include <ascend/utilities/error.h>
22 #include <test/common.h>
23
24 //#define TEST_SYM_DEBUG
25 #ifdef TEST_SYM_DEBUG
26 # define MSG CONSOLE_DEBUG
27 #else
28 # define MSG(ARGS...) ((void)0)
29 #endif
30
31 static void test_test1(void){
32 // test setup and destruction of the global list
33 InitSymbolTable();
34
35 symchar *s = AddSymbol("hello");
36
37 CU_TEST(NULL!=AscFindSymbol(s));
38 //CU_TEST(NULL==AscFindSymbol("hellox"));
39 CU_TEST(NULL==AscFindSymbol(s+1));
40 CU_TEST(NULL==AscFindSymbol(s-1));
41
42 CU_TEST(0==strcmp(SCP(s),"hello"));
43
44 char *c = "XaaaabaaaaAaaaabaaaaAaaaabaaaaAaaaabaaaaAaaaabaaaaAaaaabaaaaAaaaabaaaaAaaaabaaaaAaaaabaaaaAaaaabaaaa\
45 XaaaabaaaaAaaaabaaaaAaaaabaaaaAaaaabaaaaAaaaabaaaaAaaaabaaaaAaaaabaaaaAaaaabaaaaAaaaabaaaaAaaaabaaaa\
46 XaaaabaaaaAaaaabaaaaAaaaabaaaaAaaaabaaaaAaaaabaaaaAaaaabaaaaAaaaabaaaaAaaaabaaaaAaaaabaaaaAaaaabaaaa\
47 XaaaabaaaaAaaaabaaaaAaaaabaaaaAaaaabaaaaAaaaabaaaaAaaaabaaaaAaaaabaaaaAaaaabaaaaAaaaabaaaaAaaaabaaaa\
48 XaaaabaaaaAaaaabaaaaAaaaabaaaaAaaaabaaaaAaaaabaaaaAaaaabaaaaAaaaabaaaaAaaaabaaaaAaaaabaaaaAaaaabaaaa\
49 YaaaabaaaaAaaaabaaaaAaaaabaaaaAaaaabaaaaAaaaabaaaaAaaaabaaaaAaaaabaaaaAaaaabaaaaAaaaabaaaaAaaaabaaaa\
50 YaaaabaaaaAaaaabaaaaAaaaabaaaaAaaaabaaaaAaaaabaaaaAaaaabaaaaAaaaabaaaaAaaaabaaaaAaaaabaaaaAaaaabaaaa\
51 YaaaabaaaaAaaaabaaaaAaaaabaaaaAaaaabaaaaAaaaabaaaaAaaaabaaaaAaaaabaaaaAaaaabaaaaAaaaabaaaaAaaaabaaaa\
52 YaaaabaaaaAaaaabaaaaAaaaabaaaaAaaaabaaaaAaaaabaaaaAaaaabaaaaAaaaabaaaaAaaaabaaaaAaaaabaaaaAaaaabaaaa\
53 YaaaabaaaaAaaaabaaaaAaaaabaaaaAaaaabaaaaAaaaabaaaaAaaaabaaaaAaaaabaaaaAaaaabaaaaAaaaabaaaaAaaaabaaaa\
54 ZaaaabaaaaAaaaabaaaaAaaaabaaaaAaaaabaaaaAaaaabaaaaAaaaabaaaaAaaaabaaaaAaaaabaaaaAaaaabaaaaAaaaabaaaa";
55
56 symchar *s2 = AddSymbol(c);
57 CU_TEST(NULL!=AscFindSymbol(s2));
58
59 PrintTab(0);
60
61 DestroySymbolTable();
62 DestroyStringSpace();
63 }
64
65 /*===========================================================================*/
66 /* Registration information */
67
68 /* the list of tests */
69
70 #define TESTS(T) \
71 T(test1)
72
73 REGISTER_TESTS_SIMPLE(compiler_symtab, TESTS)
74

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22