conformance_test/positive_tests added
[deliverable/titan.core.git] / conformance_test / positive_tests / 06_types_and_values / 0603_type_compatibility / 060301_non-structured_types / Sem_060301_non_structured_types_002.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:6.3.1, Ensure that the IUT correctly handles assignments from compatible size restrictions
13 ** @verdict pass accept, ttcn3verdict:pass
14 ***************************************************/
15
16 module Sem_060301_non_structured_types_002 {
17 type integer ConstrainedInt[1..2];
18 type float ConstrainedFloat[1..2];
19 type charstring ConstrainedChar length (1..2);
20 type universal charstring ConstrainedUChar length (1..2);
21 type bitstring ConstrainedBitString length (1..2);
22 type hexstring ConstrainedHexString length (1..2);
23
24 type component GeneralComp {
25 }
26 /**
27 * @desc Equals method for floats
28 * @return true if abs(f1 - f2) < 1.E-6
29 */
30 function f_isFloatNear(in float f1, in float f2) return boolean {
31 var float delta := f1-f2;
32 if (delta < 0.0) {
33 delta := 0.0 - delta;
34 }
35 return delta < 1E-6;
36 }
37
38 testcase TC_Sem_060301_non_structured_types_002() runs on GeneralComp {
39
40 var integer v_int[2]:={5,4};
41 var ConstrainedInt v_constrainedInt;
42 var float v_float[2]:={5.0,4.0};
43 var ConstrainedFloat v_constrainedFloat;
44 var charstring v_char := "jk";
45 var ConstrainedChar v_constrainedChar;
46 var universal charstring v_uChar := char(0, 0, 1, 112);
47 var ConstrainedUChar v_constrainedUChar;
48 var bitstring v_bitstr := '10'B;
49 var ConstrainedBitString v_constrainedBitstr;
50 var hexstring v_hexstr := '1B'H;
51 var ConstrainedHexString v_constrainedHexstr;
52
53
54 v_constrainedInt:=v_int;
55 v_constrainedFloat:=v_float;
56 v_constrainedChar:=v_char;
57 v_constrainedUChar:=v_uChar;
58 v_constrainedBitstr:=v_bitstr;
59 v_constrainedHexstr:=v_hexstr;
60
61 if (
62 (v_constrainedInt[1]==5) and
63 (v_constrainedInt[2]==4) and
64 (f_isFloatNear(v_constrainedFloat[1],5.0)) and
65 (f_isFloatNear(v_constrainedFloat[2],4.0)) and
66 (v_constrainedChar=="jk") and
67 (v_constrainedUChar==char(0, 0, 1, 112)) and
68 (v_constrainedBitstr=='10'B) and
69 (v_constrainedHexstr=='1B'H)
70 ) {
71 setverdict(pass);
72 }
73 else {
74 setverdict(fail);
75 }
76 }
77
78 control{
79 execute(TC_Sem_060301_non_structured_types_002());
80 }
81
82 }
This page took 0.033005 seconds and 5 git commands to generate.