/******************************************************************************
 * Copyright (c) ETSI 2017.
 *
 * This file is subject to copyrights owned by ETSI. Non-exclusive permission
 * is hereby granted, free of charge, to copy, reproduce and amend this file
 * under the following conditions: It is provided "as is", without warranty of any
 * kind, expressed or implied.
 * 
 * ETSI shall never be liable for any claim, damages, or other liability arising
 * from its use or inability of use.This permission does not apply to any documentation
 * associated with this file for which ETSI keeps all rights reserved. The present
 * copyright notice shall be included in all copies of whole or part of this
 * file and shall not imply any sub-license right.
 *
 * Modified by: Adrien Kirjak
 *
 ** @version  0.0.1
 ** @purpose  1:16.1.2, Ensure that predefined decvalue and decvalue_unichar function works properly in case of uninitialized encode value is given
 ** @verdict  pass accept, ttcn3verdict:pass
 ***************************************************/

/* The following requirements are tested:
 * all actual in and inout parameters shall be initialized with the following exceptions:
 * 16.1.2. Restriction a.3 : the encoded_value parameter of the decvalue and decvalue_unichar function may be uninitialized.*/

module Sem_160102_predefined_functions_080 {
    type enumerated E { one(1), two(2), three(3) } with { variant "32 bit"};

    type component GeneralComp {
    }

    testcase TC_Sem_160102_predefined_functions_080 () runs on GeneralComp {
        
        var bitstring v_test;    // uninitialized value for encoded_value parameter decvalue() input
        var universal charstring v_test_enc_8; 
		// uninitialized value encoded_value parameter for decvalue_unichar() input
		var E v_decoded;
        var E v_decoded_8;
        
		var integer v_res := decvalue(v_test, v_decoded);
        var integer v_res_8 := decvalue_unichar(v_test_enc_8, v_decoded_8, "UTF-8");
      
        if(match(v_res,1)){
            setverdict(pass,"Decoded ", v_decoded , " with result ", v_res);
        }else{
             setverdict(fail,"Decode failed ", v_decoded , " with result ", v_res);
        }
        
        if(match(v_res_8,1)){
            setverdict(pass,"Decoded ", v_decoded_8 , " with result ", v_res_8);
        }else{
             setverdict(fail,"Decode failed ", v_decoded_8 , " with result ", v_res_8);
        }
    }

    control{
        execute(TC_Sem_160102_predefined_functions_080());
    }
} with {encode "RAW" }
