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_OK { | |
9 | ||
10 | type component PDTestComponent {}; | |
11 | ||
12 | /*--- FLOAT2INT --------------------------------------------------*/ | |
13 | ||
14 | ||
15 | modulepar integer f2ipar1 := float2int(5E-1) | |
16 | modulepar integer f2ipar2 := float2int(0.345) | |
17 | modulepar integer f2ipar3 := float2int(-0.345) | |
18 | modulepar integer f2ipar4 := float2int(-5E0) | |
19 | modulepar integer f2ipar5 := float2int(12345678910000.0) | |
20 | modulepar integer f2ipar6 := float2int(12345678910e+4) | |
21 | modulepar integer f2ipar7 := float2int(4294967296.0) | |
22 | ||
23 | testcase float_to_int() runs on PDTestComponent{ | |
24 | ||
25 | if ((f2ipar1 == 0) | |
26 | and (f2ipar1 == float2int(5E-1))) | |
27 | {setverdict(pass);} | |
28 | else {setverdict(fail);} | |
29 | if ((f2ipar2 == 0) | |
30 | and (f2ipar2 == float2int(0.345))) | |
31 | {setverdict(pass);} | |
32 | else {setverdict(fail);} | |
33 | if ((f2ipar3 == 0) | |
34 | and (f2ipar3 == float2int(-0.345))) | |
35 | {setverdict(pass);} | |
36 | else {setverdict(fail);} | |
37 | if ((f2ipar4 == -5) | |
38 | and (f2ipar4 == float2int(-5E0))) | |
39 | {setverdict(pass);} | |
40 | else {setverdict(fail);} | |
41 | // Tests added for HL22929. | |
42 | if ((f2ipar5 == 12345678910000) | |
43 | and (f2ipar5 == float2int(12345678910000.0))) | |
44 | {setverdict(pass);} | |
45 | else {setverdict(fail);} | |
46 | if ((f2ipar6 == 123456789100000) | |
47 | and (f2ipar6 == float2int(12345678910e+4))) | |
48 | {setverdict(pass);} | |
49 | else {setverdict(fail);} | |
50 | if ((f2ipar7 == 4294967296) | |
51 | and (f2ipar7 == float2int(4294967296.0))) | |
52 | {setverdict(pass);} | |
53 | else {setverdict(fail);} | |
54 | var float f2ivar1 := 12345678910000.0 | |
55 | var float f2ivar2 := 12345678910e+4 | |
56 | var float f2ivar3 := 4294967296.0 | |
57 | if ((float2int(f2ivar1) == 12345678910000) | |
58 | and (float2int(f2ivar1) == float2int(12345678910000.0))) | |
59 | {setverdict(pass);} | |
60 | else {setverdict(fail);} | |
61 | if ((float2int(f2ivar2) == 123456789100000) | |
62 | and (float2int(f2ivar2) == float2int(123456789100000.0))) | |
63 | {setverdict(pass);} | |
64 | else {setverdict(fail);} | |
65 | if ((float2int(f2ivar3) == 4294967296) | |
66 | and (float2int(f2ivar3) == float2int(4294967296.0))) | |
67 | {setverdict(pass);} | |
68 | else {setverdict(fail);} | |
69 | ||
70 | } | |
71 | ||
72 | /*--- FLOAT2STR --------------------------------------------------*/ | |
73 | ||
74 | modulepar charstring f2spar := "1234567890123456789012345678901234567890" | |
75 | ||
76 | modulepar charstring f2spar1 := float2str(5E-1) | |
77 | modulepar charstring f2spar2 := float2str(-5E-1) | |
78 | modulepar charstring f2spar3 := float2str(0.345) | |
79 | modulepar charstring f2spar4 := float2str(-0.345) | |
80 | modulepar charstring f2spar5 := float2str(0.1234567) | |
81 | modulepar charstring f2spar6 := float2str(123456748901.0) | |
82 | modulepar charstring f2spar7 := float2str(123456758901.0) | |
83 | ||
84 | ||
85 | testcase float_to_str() runs on PDTestComponent{ | |
86 | ||
87 | if ((f2spar1 == "0.500000") | |
88 | and (f2spar1 == float2str(5E-1))) | |
89 | {setverdict(pass);} | |
90 | else {setverdict(fail);} | |
91 | if ((f2spar2 == "-0.500000") | |
92 | and (f2spar2 == float2str(-5E-1))) | |
93 | {setverdict(pass);} | |
94 | else {setverdict(fail);} | |
95 | if ((f2spar3 == "0.345000") | |
96 | and (f2spar3 == float2str(0.345))) | |
97 | {setverdict(pass);} | |
98 | else {setverdict(fail);} | |
99 | if ((f2spar4 == "-0.345000") | |
100 | and (f2spar4 == float2str(-0.345))) | |
101 | {setverdict(pass);} | |
102 | else {setverdict(fail);} | |
103 | if ((f2spar5 == "0.123457") | |
104 | and (f2spar5 == float2str(0.1234567))) | |
105 | {setverdict(pass);} | |
106 | else {setverdict(fail);} | |
107 | if ((f2spar6 == "1.234567e+11") | |
108 | and (f2spar6 == float2str(123456748901.0))) | |
109 | {setverdict(pass);} | |
110 | else {setverdict(fail);} | |
111 | if ((f2spar7 == "1.234568e+11") | |
112 | and (f2spar7 == float2str(123456758901.0))) | |
113 | {setverdict(pass);} | |
114 | else {setverdict(fail);} | |
115 | ||
116 | } | |
117 | ||
118 | control { | |
119 | execute (float_to_int()); | |
120 | execute (float_to_str()); | |
121 | } | |
122 | ||
123 | } |