fixed compilation error caused by the previous commit
[deliverable/titan.core.git] / hello / hello_world.ttcn
CommitLineData
d44e3c4f 1/******************************************************************************
2 * Copyright (c) 2000-2016 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 * Contributors:
9 * Balasko, Jeno
10 *
11 ******************************************************************************/
3abe9331 12module hello_world
d44e3c4f 13{
3abe9331 14//====================== Data Types ======================
15type record of charstring RoC; //unconstrained array of character strings
16
d44e3c4f 17//====================== Port Types ======================
3abe9331 18type port MYPORT message {
19 inout charstring
d44e3c4f 20} with {extension "internal"}
21
22//====================== Component Types ======================
3abe9331 23type component MYCOMP {
24 const integer c_MyCompDummyConstant := 42;
25 var integer v_MyCompDummyVariable1, v_MyCompDummyVariable2 := 1;
26 timer T_MyCompDummyTimer;
d44e3c4f 27 port MYPORT myport
3abe9331 28}
29
30//====================== Constants ======================
d44e3c4f 31const charstring ws0 := "(\n| )#(0,)"
32
33//====================== Templates ======================
3abe9331 34//Strings containing the words "hello" and "word", in all small, or
35//all capital letters, or small letters with first letter capital;
d44e3c4f 36//exclamation mark is optional; whitespaces allowed
3abe9331 37template charstring t_expected :=
38 pattern "{ws0}(((h|H)ello {ws0}(w|W)orld)|HELLO {ws0}WORLD){ws0}!#(0,1){ws0}"
d44e3c4f 39
40//====================== Functions ======================
3abe9331 41function f_PTC(charstring pl_toSend) runs on MYCOMP {
42 myport.send(pl_toSend);
d44e3c4f 43}
44
45//====================== Testcases ======================
3abe9331 46testcase TC(charstring pl_toSend) runs on MYCOMP {
47 var charstring vl_received;
48 var MYCOMP vl_PTC := MYCOMP.create alive;
49 connect (self:myport,vl_PTC:myport);
50 vl_PTC.start(f_PTC(pl_toSend));
51 T_MyCompDummyTimer.start(5.0);
52 alt {
53 [] myport.receive(t_expected)-> value vl_received {
54 setverdict(pass,"expected message received: ",vl_received)
55 }
56 [] myport.receive (charstring:?) -> value vl_received{
57 setverdict(fail,"Unexpected message received: ",vl_received)
58 }
59 [] T_MyCompDummyTimer.timeout { setverdict(inconc);}
d44e3c4f 60 }
61}
62
63//=========================================================================
64// Control Part
65//=========================================================================
3abe9331 66control {
67 var RoC vl_inputs := {
68 "HELLO WORLD!",
69 "hello world",
70 "Hello World!",
71 "hello WORLD!",
72 "hELLO wORLD!",
73 "helloworld!"
74 }
75 var integer i, vl_noStrings := sizeof(vl_inputs);
76 for (i:=0; i< vl_noStrings; i:=i+1){
77 execute (TC(vl_inputs[i]),5.0)
78 }
79
d44e3c4f 80 //3 pass, 3 fail expected
81} // end of control part
82
83} // end of module
This page took 0.029905 seconds and 5 git commands to generate.