Titan Core Initial Contribution
[deliverable/titan.core.git] / regression_test / pattern_quadruples / pattern_quadruples.ttcn
1 /******************************************************************************
2 * Copyright (c) 2000-2014 Ericsson Telecom AB
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 ******************************************************************************/
8 module pattern_quadruples
9 {
10 type component univchar_comp {};
11
12 testcase univ_match() runs on univchar_comp {
13 var universal charstring ustr;
14 const universal charstring custr := char(1, 21, 0, 122);
15 var template universal charstring utmp := pattern "{custr}[a-zA-Z\q{0, 0, 255, 24}-\q{0, 2, 12, 230}]";
16 template universal charstring utmp2 := pattern "{utmp}[^0-9]";
17
18 var boolean b := true;
19 var integer i;
20 const integer l1 := unichar2int(char(0, 0, 255, 24));
21 const integer l2 := unichar2int(char(0, 2, 12, 230));
22 const integer l := unichar2int(char(0, 2, 12, 255));
23 for (i := 0; i <= l and b == true; i := i + 1) {
24 ustr := char(1, 21, 0, 122) & int2unichar(i) & "a";
25 b:= match(ustr, utmp2);
26 if (i < 65 or (i > 90 and i < 97) or (i > 122 and i < l1) or i > l2) {
27 b := not b;
28 }
29 }
30 if (b) {
31 setverdict(pass);
32 } else {
33 setverdict(fail);
34 }
35 }
36
37 testcase univ_match_neg() runs on univchar_comp {
38 var universal charstring ustr;
39 template universal charstring utmp := pattern "[^\q{0, 1, 123, 12}-\q{0, 2, 203, 255}]";
40
41 var boolean b := true;
42 var integer i;
43 const integer l1 := unichar2int(char(0, 1, 123, 12));
44 const integer l2 := unichar2int(char(0, 2, 203, 255));
45 const integer l := unichar2int(char(0, 3, 0, 0));
46 for (i := 0; i <= l and b == true; i := i + 1) {
47 ustr := int2unichar(i);
48 b:= match(ustr, utmp);
49 if (i >= l1 and i <= l2) {
50 b := not b;
51 }
52 }
53 if (b) {
54 setverdict(pass);
55 } else {
56 setverdict(fail);
57 }
58 }
59
60 testcase univ_regexp() runs on univchar_comp {
61 var universal charstring uinput := " simple text for a regexp example ";
62 var universal charstring uregexp;
63
64 var universal charstring expected[0..2] := { " simple ", "text", " for a regexp example " };
65
66 var charstring ustrpattern := "(?+)(text)(?+)";
67
68 var integer i;
69 for (i := 0; i <= 2; i := i + 1) {
70 uregexp := regexp(uinput, ustrpattern, i);
71 if (uregexp != expected[i]) {
72 setverdict(fail, "not equal at ", i);
73 }
74 }
75
76 setverdict(pass);
77 }
78
79 testcase univ_from_charstr_pattern() runs on univchar_comp {
80 template charstring t_cs := pattern "foo.*";
81 template universal charstring t_us := t_cs; // not an error anymore
82
83 var charstring foobar_c := "foo.bar";
84 var universal charstring foobar_u := "foo.bar";
85
86 if (not match(foobar_c, t_cs)) { setverdict(fail, "cstr mismatch,", match(foobar_c, t_cs)); }
87 if (not match(foobar_u, t_us)) { setverdict(fail, "ustr mismatch,", match(foobar_u, t_us)); }
88 setverdict(pass);
89 }
90
91 control {
92 execute(univ_match());
93 execute(univ_match_neg());
94 execute(univ_regexp());
95 execute(univ_from_charstr_pattern());
96 }
97 }
This page took 0.033833 seconds and 5 git commands to generate.