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_018.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 predefined decvalue function performs decoding if there are more bits than needed
13 ** @verdict pass accept, ttcn3verdict:pass
14 ***************************************************/
15
16 // The following requirements are tested:
17 // (C.5.2)
18 // The decvalue function decodes a bitstring into a value. The test system shall suppose that
19 // the bitstring encoded_value represents an encoded instance of the actual type of decoded_value.
20 // If the decoding was successful, then the used bits are removed from the parameter encoded_value,
21 // the rest is returned (in the parameter encoded_value), and the decoded value is returned
22 // in the parameter decoded_value. The function shall return an integer value to indicate success
23 // or failure of the decoding below:
24 // â\80¢ The return value 0 indicates that decoding was successful.
25
26 module Sem_160102_predefined_functions_018 {
27 type integer I with { variant "32 bit"};
28
29 type component GeneralComp {
30 }
31
32 testcase TC_Sem_160102_predefined_functions_018 () runs on GeneralComp {
33 const bitstring c_suffix := '11111111'B;
34 var bitstring v_test := int2bit(0, 32) & c_suffix; // 8 excess bits
35 var I v_decoded;
36 var integer v_res := decvalue(v_test, v_decoded);
37 // expected result:
38 // v_res: 0 (success)
39 // v_decoded: 0
40 // v_test: '11111111'B (8 excess bits shall be returned)
41 if (match(v_res, 0) and match(v_decoded, 0) and match(v_test, c_suffix)) {
42 setverdict(pass);
43 } else {
44 setverdict(fail, "Unexpected decoding result");
45 }
46 }
47
48 control{
49 execute(TC_Sem_160102_predefined_functions_018());
50 }
51 }
This page took 0.046616 seconds and 5 git commands to generate.