]> git.ipfire.org Git - thirdparty/squid.git/blob - test-suite/ESIExpressions.cc
SourceFormat Enforcement
[thirdparty/squid.git] / test-suite / ESIExpressions.cc
1 /*
2 * Copyright (C) 1996-2014 The Squid Software Foundation and contributors
3 *
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
7 */
8
9 /* DEBUG: section 86 ESI Expressions */
10
11 #include "squid.h"
12 #include "esi/Expression.h"
13
14 int
15 main ()
16 {
17 char const *expressions[] = {
18 "!(1==1)", "!(1!=1)", "1!=1", "!1==1", "1==1",
19 "1 <=1","2<=1", "1 < 1", "1 < 2", "-1 < 1","!-1<1",
20 "1>2","2>1","2>=2", "2>3", "1==1&1==1","1==1&1==0",
21 "!('a'<='c')",
22 "(1==1)|('abc'=='def')",
23 "(4!=5)&(4==5)",
24 "(1==1)|(2==3)&(3==4)", /* should be true because of precedence */
25 "(1 & 4)",
26 "(\"abc\" | \"edf\")", "1==1==1",
27 "!('')",
28 /* End of array */""
29 };
30
31 int results[] = {0, 1, 0, 0, 1,
32 1, 0, 0, 1, 1,
33 0, 0, 1, 1, 0,
34 1, 0, 0, 1, 0,
35 1, 0, 0, 0, 0,
36 1, 0
37 };
38
39 int i = 0;
40
41 while (strlen (expressions[i])) {
42 int result = ESIExpression::Evaluate (expressions[i]);
43 #if VERBOSEDEBUG
44
45 printf("Expr '%s' = '%s' (expected %s)\n", expressions[i],
46 result ? "true" : "false",
47 results[i] ? "true" : "false");
48 #endif
49
50 if (result != results[i])
51 return 1;
52
53 ++i;
54 }
55
56 return 0;
57 }
58