/******************************************************************************
 * 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 the IUT recognizes predefined functions and correctly evaluates them (as specified by Annex C)
 ** @verdict  pass accept, ttcn3verdict:pass
 ***************************************************/

module Sem_160102_predefined_functions_007 {
    type enumerated MyEnumeratedType {e_black, e_white};
    type record of integer IntegerList;

    type record MyRecord {
        boolean field1,
        record of integer field2,
        integer field3,
        MyEnumeratedType field4 optional
    }

    type component GeneralComp {
    }
	
    testcase TC_Sem_160102_predefined_functions_007 () runs on GeneralComp {
        template MyRecord template1 := {
            field1 := true,
            field2 := { permutation(2, 3), ? },
            field3 := 5,
            field4 := omit
        }
        template MyRecord template2 := {
            field1 := true,
            field2 := {permutation(2, 3)},
            field3 := 6,
            field4 := omit
        }
        template IntegerList template3 := { 1, 2, 3, * } length(1..3) ;

        if(lengthof(charstring : "test")!=4) {
          setverdict(fail, "lengthof(charstring : ""test"")");
        }
        if (lengthof(universal charstring : "test")!=4) {
          setverdict(fail, "lengthof(universal charstring : ""test"")");
        }
        if (lengthof('010'B)!=3) {		// STF409: value definitions are interpreted as templates here
           setverdict(fail, "lengthof('010'B)");
        }
        if (lengthof('55'H)!=2) {		// STF409: value definitions are interpreted as templates here
           setverdict(fail, "lengthof('55'H)");
        }
        if (lengthof('55'O)!=1) {		// STF409: value definitions are interpreted as templates here
          setverdict(fail, "lengthof('55'O)");
        }
        if  (lengthof(charstring : pattern "t??t")!=4) {
          setverdict(fail, "lengthof(charstring : pattern ""t??t"")");
        }
        if  (lengthof(bitstring : '1??1'B)!=4) {
          setverdict(fail, "lengthof(bitstring : '1??1'B)");
        }
        if  (lengthof(hexstring : '1*1'H length(8))!=8) {
        	setverdict(fail, "lengthof(hexstring : '1*1'H length(8))");
        }
        if  (lengthof(octetstring : '00?FF'O length(3))!=3) {
        	setverdict(fail, "lengthof(octetstring : '00?FF'O length(3))");
        }
        if  (lengthof(octetstring : 'AB?'O)!=2) {
        	setverdict(fail, "lengthof(octetstring : 'AB?'O)");
        }
        if  (sizeof(template1.field2)!=3) {
        	setverdict(fail, "sizeof(", template1.field2, ")");
        }
        if  (sizeof(template2.field2)!=2) {
        	setverdict(fail, "sizeof(", template2.field2, ")");
        }
        if  (lengthof(template3)!=3) {
        	setverdict(fail, "lengthof(", template3, ")");
        }
        setverdict(pass);
    }

    control{
        execute(TC_Sem_160102_predefined_functions_007());
    }
}
