/******************************************************************************
 * Copyright (c) 2000-2025 Ericsson Telecom AB
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
 *
 * Contributors:
 *   Szabados, Kristof *
 ******************************************************************************/
module BER_EncDec_162 {

import from BER_EncDecA_162 all;


type float BERPDU;

external function dec_BER_PDU(in octetstring os, out BERPDU pdu)
  with { extension "prototype(fast) decode(BER:BER_ACCEPT_ALL) " }

// pi: 31415926.E-7
const octetstring der_encoded := '090D2033313431353932362E452D37'O;
const BERPDU myValue := 3.1415926;


type component TempComp {}
testcase TC() runs on TempComp {

var BERPDU der_decoded, cer_decoded;

@try {
  dec_BER_PDU(der_encoded, der_decoded);
  if (der_decoded==myValue) {setverdict(pass);} else {setverdict(fail);}
} @catch (msg) {
  var template charstring msg_exp := pattern "*Dynamic test case error: While BER-decoding type '@BER_EncDec_162.BERPDU': While decoding REAL type: This is a reserved value: 0x20 \(See X.690 8.5.7\)*";
  if (not match(msg, msg_exp)) {
    setverdict(fail, "Invalid error message: ", msg);
  } else {
    setverdict(pass);
  }
}
} 

control { 
execute (TC()) 
}
}
