TTCN-3 编码解码相关模块引入
作者:网络转载 发布时间:[ 2013/11/27 16:15:51 ] 推荐标签:
//具体进行编码的函数(编码工厂),根据不同的类型调用函数进行编码
void encode(MyBinaryString *msg, TciValue value)
{
TciType type;
TciTypeClassType kind;
printf("
In function encode()
");
tci_assert(value != NULL, "Illegal value");
type = tciGetType(value);
tci_assert(type != NULL, "Illegal type");
kind = tciGetTypeClass(type);
switch(kind) {
case TCI_OCTETSTRING_TYPE:{
String ostring;
ostring = tciGetOStringValue(value);
tci_assert(ostring, "Illegal octet string value");
/* encode octet string */
encode_octetstring(msg, ostring);
}
break;
case TCI_RECORD_TYPE:
case TCI_SET_TYPE:
case TCI_RECORD_OF_TYPE:
case TCI_SET_OF_TYPE:
case TCI_ANYTYPE_TYPE:
case TCI_UNION_TYPE:
case TCI_UNIVERSAL_CHAR_TYPE:
case TCI_UNIVERSAL_CHARSTRING_TYPE:
case TCI_VERDICT_TYPE:
case TCI_INTEGER_TYPE:
case TCI_FLOAT_TYPE:
case TCI_CHAR_TYPE:
case TCI_BITSTRING_TYPE:
case TCI_CHARSTRING_TYPE:
case TCI_ENUMERATED_TYPE:
case TCI_ADDRESS_TYPE:
case TCI_BOOLEAN_TYPE:
case TCI_HEXSTRING_TYPE:
case TCI_OBJID_TYPE:
{
tci_assert(0, "Unsupported type kind in Encoder");
break;
}
default:
{
tci_assert(0, "Unkonw type kind in Encoder");
break;
}
}//end of swich
printf("
Leave function encode()
");
}
//编码的主要函数,每次需要对TciValue进行编码都会被调用
BinaryString tciEncode(TciValue value)
{
MyBinaryString msg;
TciType type;
unsigned long length;
int i;
printf("
In function tciEncode()
");
//initialize
msg.allocated = 0;
msg.string.data = NULL;
msg.string.bits = 0;
msg.string.aux = NULL;
//Lookups type identifier of the specified value.
//Returns the type of the specified value
//Returns NULL in case of error.
type = tciGetType(value);
tci_assert_wret(type != NULL, "Illegal type", msg.string);
//start encoding
encode(&msg, value);
printf("
In function tciEncode() Encoding finishes and we get the following result:
");
printf("code len: %ld
",msg.string.bits);
encode_printing(msg.string);
//check if encoding is successed
tci_assert(msg.string.bits%8==0, "Encode failed: the packets length must be multiples of byte.");
printf("
Leave function tciEncode()
");
return msg.string;
}
相关推荐
更新发布
功能测试和接口测试的区别
2023/3/23 14:23:39如何写好测试用例文档
2023/3/22 16:17:39常用的选择回归测试的方式有哪些?
2022/6/14 16:14:27测试流程中需要重点把关几个过程?
2021/10/18 15:37:44性能测试的七种方法
2021/9/17 15:19:29全链路压测优化思路
2021/9/14 15:42:25性能测试流程浅谈
2021/5/28 17:25:47常见的APP性能测试指标
2021/5/8 17:01:11