Commit | Line | Data |
---|---|---|
970ed795 | 1 | /****************************************************************************** |
3abe9331 | 2 | * Copyright (c) 2000-2015 Ericsson Telecom AB |
970ed795 EL |
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 float_to_SW { //^In TTCN-3 module `float_to_SW':// | |
9 | ||
10 | type component PDTestComponent {}; | |
11 | ||
12 | /*--- FLOAT2INT --------------------------------------------------*/ | |
13 | ||
14 | ||
15 | const integer f2icon1 := float2int(5E-1) | |
16 | const integer f2icon2 := float2int(0.345) | |
17 | const integer f2icon3 := float2int(-0.345) | |
18 | const integer f2icon4 := float2int(-5E0) | |
19 | const integer f2icon5 := float2int(12345678910000.0) | |
20 | const integer f2icon6 := float2int(12345678910e+4) | |
21 | const integer f2icon7 := float2int(4294967296.0) | |
22 | ||
23 | testcase float_to_int() runs on PDTestComponent{ //In testcase definition// | |
24 | ||
25 | if ((f2icon1 == 0) | |
26 | and (f2icon1 == float2int(5E-1))) | |
27 | {setverdict(pass);} | |
28 | else {setverdict(fail);} //^In else statement// \ | |
29 | //^warning\: Control never reaches this code because of previous effective condition\(s\)// | |
30 | if ((f2icon2 == 0) | |
31 | and (f2icon2 == float2int(0.345))) | |
32 | {setverdict(pass);} | |
33 | else {setverdict(fail);} //^In else statement// \ | |
34 | //^warning\: Control never reaches this code because of previous effective condition\(s\)// | |
35 | if ((f2icon3 == 0) | |
36 | and (f2icon3 == float2int(-0.345))) | |
37 | {setverdict(pass);} | |
38 | else {setverdict(fail);} //^In else statement// \ | |
39 | //^warning\: Control never reaches this code because of previous effective condition\(s\)// | |
40 | if ((f2icon4 == -5) | |
41 | and (f2icon4 == float2int(-5E0))) | |
42 | {setverdict(pass);} | |
43 | else {setverdict(fail);} //^In else statement// \ | |
44 | //^warning\: Control never reaches this code because of previous effective condition\(s\)// | |
45 | // Tests added for HL22929. | |
46 | if ((f2icon5 == 12345678910000) | |
47 | and (f2icon5 == float2int(12345678910000.0))) | |
48 | {setverdict(pass);} | |
49 | else {setverdict(fail);} //^In else statement// \ | |
50 | //^warning\: Control never reaches this code because of previous effective condition\(s\)// | |
51 | if ((f2icon6 == 123456789100000) | |
52 | and (f2icon6 == float2int(12345678910e+4))) | |
53 | {setverdict(pass);} | |
54 | else {setverdict(fail);} //^In else statement// \ | |
55 | //^warning\: Control never reaches this code because of previous effective condition\(s\)// | |
56 | if ((f2icon7 == 4294967296) | |
57 | and (f2icon7 == float2int(4294967296.0))) | |
58 | {setverdict(pass);} | |
59 | else {setverdict(fail);} //^In else statement// \ | |
60 | //^warning\: Control never reaches this code because of previous effective condition\(s\)// | |
61 | } | |
62 | ||
63 | /*--- FLOAT2STR --------------------------------------------------*/ | |
64 | ||
65 | const charstring f2scon := "1234567890123456789012345678901234567890" | |
66 | ||
67 | const charstring f2scon1 := float2str(5E-1) | |
68 | const charstring f2scon2 := float2str(-5E-1) | |
69 | const charstring f2scon3 := float2str(0.345) | |
70 | const charstring f2scon4 := float2str(-0.345) | |
71 | const charstring f2scon5 := float2str(0.1234567) | |
72 | const charstring f2scon6 := float2str(123456748901.0) | |
73 | const charstring f2scon7 := float2str(123456758901.0) | |
74 | ||
75 | ||
76 | testcase float_to_str() runs on PDTestComponent{ //In testcase definition// | |
77 | ||
78 | if ((f2scon1 == "0.500000") | |
79 | and (f2scon1 == float2str(5E-1))) | |
80 | {setverdict(pass);} | |
81 | else {setverdict(fail);} //^In else statement// \ | |
82 | //^warning\: Control never reaches this code because of previous effective condition\(s\)// | |
83 | if ((f2scon2 == "-0.500000") | |
84 | and (f2scon2 == float2str(-5E-1))) | |
85 | {setverdict(pass);} | |
86 | else {setverdict(fail);} //^In else statement// \ | |
87 | //^warning\: Control never reaches this code because of previous effective condition\(s\)// | |
88 | if ((f2scon3 == "0.345000") | |
89 | and (f2scon3 == float2str(0.345))) | |
90 | {setverdict(pass);} | |
91 | else {setverdict(fail);} //^In else statement// \ | |
92 | //^warning\: Control never reaches this code because of previous effective condition\(s\)// | |
93 | if ((f2scon4 == "-0.345000") | |
94 | and (f2scon4 == float2str(-0.345))) | |
95 | {setverdict(pass);} | |
96 | else {setverdict(fail);} //^In else statement// \ | |
97 | //^warning\: Control never reaches this code because of previous effective condition\(s\)// | |
98 | if ((f2scon5 == "0.123457") | |
99 | and (f2scon5 == float2str(0.1234567))) | |
100 | {setverdict(pass);} | |
101 | else {setverdict(fail);} //^In else statement// \ | |
102 | //^warning\: Control never reaches this code because of previous effective condition\(s\)// | |
103 | if ((f2scon6 == "1.234567e+11") | |
104 | and (f2scon6 == float2str(123456748901.0))) | |
105 | {setverdict(pass);} | |
106 | else {setverdict(fail);} //^In else statement// \ | |
107 | //^warning\: Control never reaches this code because of previous effective condition\(s\)// | |
108 | if ((f2scon7 == "1.234568e+11") | |
109 | and (f2scon7 == float2str(123456758901.0))) | |
110 | {setverdict(pass);} | |
111 | else {setverdict(fail);} //^In else statement// \ | |
112 | //^warning\: Control never reaches this code because of previous effective condition\(s\)// | |
113 | } | |
114 | ||
115 | control { | |
116 | execute (float_to_int()); | |
117 | execute (float_to_str()); | |
118 | } | |
119 | ||
120 | } |