///////////////////////////////////////////////////////////////////////////////
//                                                                           //
// Copyright (c) 2000-2019 Ericsson Telecom AB                           //
//                                                                           //
// The copyright to the computer  program(s) herein  is the property of TCC. //
// The program(s) may be used and/or copied only with the written permission //
// of TCC or in accordance with  the terms and conditions  stipulated in the //
// agreement/contract under which the program(s) has been supplied.          //
//                                                                           //
///////////////////////////////////////////////////////////////////////////////
//
//  File:               SDP_test.ttcn
//  Rev:                R5A01
//  Prodnr:             CNL 113 353
//  Updated:            2009-05-25
//  Contact:            http://ttcn.ericsson.se
//  Reference:          ITU-T SDP
module SDP_test
{

import from SDP_Types all;
import from SDP_Templates all;

type component MTC {}

type record length(2) of integer intv;
type record of intv UnsuccList;

testcase tc_BasicTest() runs on MTC
{
    var SDP_Message v_SDP_Message;
    var charstring v_result;
    var integer i, j, succ_c:=0, unsucc_c:=0;
    var UnsuccList unsucc;
    for (j := 0; j < sizeof(TestMessages); j := j + 1) {
        for (i := 0; i < sizeof(TestMessages[j]); i := i + 1) {
            log("############################################");
            log("############################ ",j," : ",i);
            log("###Message to be decoded:", TestMessages[j][i])
                    f_SDP_decodeMessage(TestMessages[j][i],v_SDP_Message);
                    log("###Decoded message (to be encoded again):", v_SDP_Message)
                            v_result := f_SDP_enc_Message(v_SDP_Message);
                            log("###Re-encoded message:", v_result);

                            if (v_result == TestMessages[j][0])
                            { 
                                log("###", j," : ", i, "!!!Succesfully compared!!!");
                                setverdict(pass);
                                succ_c := succ_c + 1;
                            }
                            else 
                            {
                                log("###", j," : ", i, "!!!Comparison UNSUCCESFUL!!!");
                                setverdict(inconc);
                                unsucc[unsucc_c] := {j, i};
                                unsucc_c := unsucc_c + 1;
                            };
                            log("############################################")
        }
    }
    log("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
    log("Pass: ", succ_c, " Fail: ", unsucc_c)
            log("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
            log("Unsuccesful strings:");
            for(i:=0;i<unsucc_c;i:=i+1)
            {
                log("Index: ",unsucc[i]," MESSAGE: ",TestMessages[unsucc[i][0]][unsucc[i][1]])
            }
}

}
