]>
Commit | Line | Data |
---|---|---|
924f73bc | 1 | /* |
4ac4a490 | 2 | * Copyright (C) 1996-2017 The Squid Software Foundation and contributors |
924f73bc | 3 | * |
4e0938ef AJ |
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. | |
924f73bc | 7 | */ |
8 | ||
4e0938ef AJ |
9 | /* DEBUG: section 86 ESI Expressions */ |
10 | ||
582c2af2 | 11 | #include "squid.h" |
f99c2cfe | 12 | #include "esi/Expression.h" |
924f73bc | 13 | |
14 | int | |
15 | main () | |
16 | { | |
17 | char const *expressions[] = { | |
26ac0430 AJ |
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)", | |
f53969cc | 24 | "(1==1)|(2==3)&(3==4)", /* should be true because of precedence */ |
26ac0430 AJ |
25 | "(1 & 4)", |
26 | "(\"abc\" | \"edf\")", "1==1==1", | |
27 | "!('')", | |
28 | /* End of array */"" | |
29 | }; | |
924f73bc | 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, | |
26ac0430 AJ |
36 | 1, 0 |
37 | }; | |
924f73bc | 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 | } | |
f53969cc | 58 |