conformance_test/positive_tests added
[deliverable/titan.core.git] / conformance_test / positive_tests / 16_functions_altsteps_testcases / 1601_functions / 160102_predefined_functions / Sem_160102_predefined_functions_001.ttcn
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 * Adrien Kirjak – initial implementation
10 *
11 ** @version 0.0.1
12 ** @purpose 1:16.1.2, Ensure that the IUT recognizes predefined functions and correctly evaluates them (as specified by Annex C)
13 ** @verdict pass accept, ttcn3verdict:pass
14 ***************************************************/
15 module Sem_160102_predefined_functions_001 {
16 type enumerated EnumeratedType {e_black, e_white};
17
18 type component GeneralComp {
19 }
20
21 /**
22 * @desc Equals method for floats
23 * @return true if abs(f1 - f2) < 1.E-6
24 */
25 function f_isFloatNear(in float f1, in float f2) return boolean {
26 var float delta := f1-f2;
27 if (delta < 0.0) {
28 delta := 0.0 - delta;
29 }
30 return delta < 1E-6;
31 }
32
33 testcase TC_Sem_160102_predefined_functions_001 () runs on GeneralComp {
34 const universal charstring c_i:="i";
35 var integer v_result:=0;
36 var EnumeratedType v_enum:=e_white;
37
38 if( match(int2char(105), "i") and
39 match(int2unichar(105), c_i) and
40 match(int2bit(5,4), '0101'B) and
41 match(int2hex(55,4), '0037'H) and
42 match(int2oct(55,2), '0037'O) and
43 match(int2str(55), "55") and
44 (f_isFloatNear(int2float(5),5.0)) and
45 match(float2int(5.0), 5) and
46 match(char2int("i"), 105) and
47 match(char2oct("i"), '69'O) and
48 match(unichar2int(c_i), 105) and
49 match(bit2int('101'B), 5) and
50 match(bit2hex('110111'B), '37'H) and
51 match(bit2oct('110111'B), '37'O) and
52 match(bit2str('110111'B), "110111") and
53 match(hex2int('37'H), 55) and
54 match(hex2bit('37'H),'00110111'B) and
55 match(hex2oct('37'H), '37'O) and
56 match(hex2str('37'H), "37") and
57 match(oct2int('37'O), 55) and
58 match(oct2bit('37'O), '00110111'B) and
59 match(oct2hex('37'O), '37'H) and
60 match(oct2str('37'O), "37") and
61 match(oct2char('69'O), "i") and
62 match(str2int("55"),55) and
63 match(str2oct("55"), '55'O) and
64 (f_isFloatNear(str2float("5.5"),5.5)) and
65 match(enum2int(v_enum), 1)
66 ) {
67 setverdict(pass);
68 }
69 else {
70 setverdict(fail);
71 }
72 }
73
74 control{
75 execute(TC_Sem_160102_predefined_functions_001());
76 }
77 }
This page took 0.031547 seconds and 5 git commands to generate.