/*****************************************************************
 ** @author   STF 487
 ** @version  0.0.1
 ** @purpose  1:22.2.2, encoding parameter of @decoded redirect assignment applied to incorrect type
 ** @verdict  pass reject
 *****************************************************************/

// The following requirements are tested:
// In case the referenced field is not a universal charstring, the optional
// parameter shall not be present.

module NegSem_220202_ReceiveOperation_009 {
	type record R
    {
        integer id,
        octetstring payload
    }

	type port P message {
		inout R;
	}

    type component GeneralComp
	{
		port P p;
	}

    testcase TC_NegSem_220202_ReceiveOperation_009() 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.receive(R:?) -> value (v_res := @decoded("UTF-8") payload) {
                setverdict (pass);
            }
            [] p.receive { setverdict(pass); }
        }
    }

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