/*****************************************************************
 ** @author   STF 487
 ** @version  0.0.1
 ** @purpose  1:22.2.2, @decoded redirect assignment of a hexstring field
 ** @verdict  pass accept, ttcn3verdict:pass
 *****************************************************************/

// The following requirements are tested:
// When assigning individual fields of a message, encoded payload fields can be
// decoded prior to assignment using the @decoded modifier. In this case, the
// referenced field on the right hand sided of the assignment shall be one of the
// bitstring, hexstring, octetstring, charstring or universal charstring types. It
// shall be decoded into a value of the same type as the variable on the left hand
// side of the assignment.

module Sem_220202_ReceiveOperation_012 {
	type record R
    {
        integer id,
        hexstring payload
    }

	type port P message {
		inout R;
	}

    type component GeneralComp
	{
		port P p;
	}

    testcase TC_Sem_220202_ReceiveOperation_012() runs on GeneralComp {
        var charstring v_src := "abc", v_res;
        var hexstring v_hs := bit2hex(encvalue(v_src));
        p.send(R:{ id := 1, payload := v_hs });
        alt {
            [] p.receive(R:?) -> value (v_res := @decoded payload) {
                if (v_res == "abc") { setverdict (pass); }
                else { setverdict(fail); }
            }
            [] p.receive { setverdict(fail); }
        }
    }

    control {
        execute(TC_Sem_220202_ReceiveOperation_012(), 5.0);
    }
}