Matching results for received messages

21 views Asked by At

I am fairly new to TTCN3 and I am probably doing or thinking the wrong way. I would like to do some matching tests on a received message. I am currently doing the following :

    type record Person{
        charstring firstName,
        charstring middleName optional,
        charstring lastName
    } 

    template Person validPerson := {
        firstName := ? length (0 .. 25),
        middleName := * length (0 .. 25) ifpresent,
        lastName := ? length (0 .. 20)
    }

and the testcase is then

        alt {
            [] Port.receive(Person:?) -> value received_msg{
                if (match(received_msg, validPerson)){ setverdict(pass, "Received valid message") }
                else {
                    setverdict(fail, "Received unvalid message", received_msg)                
                }
            }

         ... some other stuff

Now what I would like to do, because I will end up having to describe many scenarios is

    type charstring String20    length(0..20);
    type charstring String25    length(0..25);

    type record ValidPerson{
        String25 firstName,
        String25 middleName optional,
        String20 lastName
    } 

And then be able to match my received message with the said record above. That would avoid me having to write over and over the lengths filters in the template. This is needed because I will be re-using the specified charstrings20 and 25 a lot later on.

Is there any way to do what I want ? If not, is there a cleaner way to do this ? Many thanks!

0

There are 0 answers