TestCodec_External.ttcn 1.34 KB
Newer Older
Yann Garcia's avatar
Yann Garcia committed
module TestCodec_External {
  
  // LibMec
  import from LocationAPI_TypesAndValues all;
  import from LocationAPI_Templates all;
  
  // TestCodec
  import from TestCodec_TestAndSystem all;
  
  testcase tc_encode_LocationInfo() runs on TCType system TCType {
    var LocationInfo v_location_info := valueof(m_location_info(10.0, 12.0, 9));
    var LocationInfo v_location_info_result;
    var universal charstring v_result;
    var universal charstring v_expected_result := "{\"latitude\":10.000000,\"longitude\":12.000000,\"accuracy\":9}";
    var bitstring v_enc_msg;
    var integer v_res;
    
    v_enc_msg := encvalue(v_location_info);
    v_result := oct2unichar(bit2oct(v_enc_msg), "UTF-8");
    log("v_result= ", v_result);
    if (match(v_expected_result, v_result)) {
      setverdict(pass, "Encoding succeed");
    } else {
      setverdict(fail, "Encoding failed");
    }
    
    v_res := decvalue(v_enc_msg, v_location_info_result);
    if (v_res == 0) {
      log("v_location_info_result= ", v_location_info_result);
      if (match(v_location_info, v_location_info_result)) {
        setverdict(pass, "Decoding succeed");
      } else {
        setverdict(fail, "Decoding failed");
      }
    } else {
      setverdict(fail, "Decoding operation failed");
    }
  } // End of testcase tc_encode_LocationInfo
  
} // End of module TestCodec_External