/*****************************************************************
 ** @author   STF 487
 ** @version  0.0.1
 ** @purpose  1:22.2.3, @decoded redirect assignment of an octetstring field
 ** @verdict  pass accept, ttcn3verdict:pass
 *****************************************************************/

// The following requirements are tested:
// Rules in clause 22.2.2 shall apply.
// 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_220203_TriggerOperation_013 {
	type record R
    {
        integer id,
        octetstring payload
    }

	type port P message {
		inout R;
	}

    type component GeneralComp
	{
		port P p;
	}

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

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