/****************************************************************************** * Copyright (c) 2000-2014 Ericsson Telecom AB * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html ******************************************************************************/ module int_to_SW { //^In TTCN-3 module `int_to_SW':// type component PDTestComponent {}; /*--- INT2BIT --------------------------------------------------*/ const bitstring i2bcon := '0000011111000001111100001111'B const bitstring i2bcon1 := int2bit(0,10); const bitstring i2bcon2 := int2bit(0,0); const bitstring i2bcon3 := int2bit(1,1) const bitstring i2bcon4 := int2bit(255,8) const bitstring i2bcon5 := int2bit(bit2int(i2bcon),lengthof(i2bcon)) const bitstring i2bcon6 := not4b int2bit(bit2int(not4b i2bcon),lengthof(i2bcon)) const bitstring i2bcon7 := int2bit(bit2int(substr(i2bcon,0,lengthof(i2bcon)/2)),lengthof(i2bcon)/2) const bitstring i2bcon8 := int2bit(bit2int(substr(i2bcon,lengthof(i2bcon)/2,lengthof(i2bcon)/2)),lengthof(i2bcon)/2) const integer i1 := 12345678910111213141516 const bitstring bs1 := '00000000000000000010100111010100001010110110010101101000100100110010100010111011111000001100'B testcase int_to_bit() runs on PDTestComponent{ //In testcase definition// if ((i2bcon1 == '0000000000'B) and (i2bcon1 == int2bit(0,10))) {setverdict(pass);} else {setverdict(fail, __LINE__);} //^In else statement// \ //^warning\: Control never reaches this code because of previous effective condition\(s\)// if ((i2bcon2 == ''B)and (i2bcon2 == int2bit(0,0))) {setverdict(pass);} else {setverdict(fail, __LINE__);} //^In else statement// \ //^warning\: Control never reaches this code because of previous effective condition\(s\)// if ((i2bcon3 == '1'B)and (i2bcon3 == int2bit(1,1))) {setverdict(pass);} else {setverdict(fail, __LINE__);} //^In else statement// \ //^warning\: Control never reaches this code because of previous effective condition\(s\)// if ((i2bcon4 == '11111111'B)and (i2bcon4 == int2bit(255,8))) {setverdict(pass);} else {setverdict(fail, __LINE__);} //^In else statement// \ //^warning\: Control never reaches this code because of previous effective condition\(s\)// if ((i2bcon5 == i2bcon)and (i2bcon5 == int2bit(bit2int(i2bcon),lengthof(i2bcon)))) {setverdict(pass);} else {setverdict(fail, __LINE__);} //^In else statement// \ //^warning\: Control never reaches this code because of previous effective condition\(s\)// if ((i2bcon6 == i2bcon)and (i2bcon5 == not4b int2bit(bit2int(not4b i2bcon),lengthof(i2bcon)))) {setverdict(pass);} else {setverdict(fail, __LINE__);} //^In else statement// \ //^warning\: Control never reaches this code because of previous effective condition\(s\)// if (i2bcon == (i2bcon7 & i2bcon8)) {setverdict(pass);} else {setverdict(fail, __LINE__);} //^In else statement// \ //^warning\: Control never reaches this code because of previous effective condition\(s\)// if (int2bit(i1, 92) == bs1) {setverdict(pass);} else {setverdict(fail, __LINE__);} //^In else statement// \ //^warning\: Control never reaches this code because of previous effective condition\(s\)// if (int2bit(12345678910111213141516, 92) == '00000000000000000010100111010100001010110110010101101000100100110010100010111011111000001100'B) {setverdict(pass);} else {setverdict(fail, __LINE__);} //^In else statement// \ //^warning\: Control never reaches this code because of previous effective condition\(s\)// if (int2bit(12345678910111213141516, 92) == bs1) {setverdict(pass);} else {setverdict(fail, __LINE__);} //^In else statement// \ //^warning\: Control never reaches this code because of previous effective condition\(s\)// if (int2bit(12345678910111213141516, 75) == '010100111010100001010110110010101101000100100110010100010111011111000001100'B) {setverdict(pass);} else {setverdict(fail, __LINE__);} //^In else statement// \ //^warning\: Control never reaches this code because of previous effective condition\(s\)// } /*--- INT2CHAR --------------------------------------------------*/ const integer i2cconi[3] := {0,1,2} type record of integer i2crtype const i2crtype i2cconii := {0,1,2} const char i2ccon1 := int2char(8 mod 6) //^warning: Obsolete type `char' was substituted with `charstring'// const char i2ccon2 := int2char(i2cconi[2]) //^warning: Obsolete type `char' was substituted with `charstring'// const char i2ccon3 := int2char(sizeof(i2cconi)-1) //^warning: Obsolete type `char' was substituted with `charstring'// const char i2ccon4 := int2char(sizeof(i2cconii)-1) //^warning: Obsolete type `char' was substituted with `charstring'// testcase int_to_char() runs on PDTestComponent{ //In testcase definition// if ((i2ccon1 == int2char(8 mod 6)) and (i2ccon1 == "")) {setverdict(pass);} else {setverdict(fail, __LINE__);} //^In else statement// \ //^warning\: Control never reaches this code because of previous effective condition\(s\)// if ((i2ccon2 == int2char(i2cconi[2])) and (i2ccon2 == "")) {setverdict(pass);} else {setverdict(fail, __LINE__);} //^In else statement// \ //^warning\: Control never reaches this code because of previous effective condition\(s\)// if ((i2ccon3 == int2char(sizeof(i2cconi)-1)) and (i2ccon3 == "")) {setverdict(pass);} else {setverdict(fail, __LINE__);} //^In else statement// \ //^warning\: Control never reaches this code because of previous effective condition\(s\)// if ((i2ccon4 == int2char(sizeof(i2cconii)-1)) and (i2ccon4 == "")) {setverdict(pass);} else {setverdict(fail, __LINE__);} //^In else statement// \ //^warning\: Control never reaches this code because of previous effective condition\(s\)// } /*--- INT2UNICHAR --------------------------------------------------*/ const universal char i2uccon1 := int2unichar(1) //^warning: Obsolete type `universal char' was substituted with `universal charstring'// const universal char i2uccon2 := int2unichar(256) //^warning: Obsolete type `universal char' was substituted with `universal charstring'// const universal char i2uccon3 := int2unichar(65536) //^warning: Obsolete type `universal char' was substituted with `universal charstring'// const universal char i2uccon4 := int2unichar(16777216) //^warning: Obsolete type `universal char' was substituted with `universal charstring'// const universal char i2uccon5 := int2unichar(2147483647) //^warning: Obsolete type `universal char' was substituted with `universal charstring'// testcase int_to_unichar() runs on PDTestComponent{ //In testcase definition// //log (i2uccon1) //log (i2uccon2) //log (i2uccon3) //log (i2uccon4) //log (i2uccon5) if ((i2uccon1 == int2unichar(1)) and (i2uccon1 == char(0, 0, 0, 1))) {setverdict(pass);} else {setverdict(fail, __LINE__);} //^In else statement// \ //^warning\: Control never reaches this code because of previous effective condition\(s\)// if ((i2uccon2 == int2unichar(256)) and (i2uccon2 == char(0, 0, 1, 0))) {setverdict(pass);} else {setverdict(fail, __LINE__);} //^In else statement// \ //^warning\: Control never reaches this code because of previous effective condition\(s\)// if ((i2uccon3 == int2unichar(65536)) and (i2uccon3 == char(0, 1, 0, 0))) {setverdict(pass);} else {setverdict(fail, __LINE__);} //^In else statement// \ //^warning\: Control never reaches this code because of previous effective condition\(s\)// if ((i2uccon4 == int2unichar(16777216)) and (i2uccon4 == char(1, 0, 0, 0))) {setverdict(pass);} else {setverdict(fail, __LINE__);} //^In else statement// \ //^warning\: Control never reaches this code because of previous effective condition\(s\)// if ((i2uccon5 == int2unichar(2147483647)) and (i2uccon5 == char(127, 255, 255, 255))) {setverdict(pass);} else {setverdict(fail, __LINE__);} //^In else statement// \ //^warning\: Control never reaches this code because of previous effective condition\(s\)// } /*--- INT2FLOAT --------------------------------------------------*/ const integer i2fconi[3] := {0,1,2} type record of integer i2frtype; const i2frtype i2fconii := {0} type float i2fflo (-1.0 .. 6.0) const float i2fcon1 := int2float(3/2) const float i2fcon2 := int2float(-3) const float i2fcon3 := int2float(lengthof("")) const float i2fcon4 := int2float(i2fconi[0]) const float i2fcon5 := int2float(i2fconii[0]) const float i2fcon8 := int2float(2147483648) const float i2fcon9 := int2float(214748364800) const float i2fcon10 := int2float(4294967296) const i2fflo i2fcon6 := int2float(20/3) const i2fflo i2fcon7 := int2float(8 mod 6) testcase int_to_float() runs on PDTestComponent{ //In testcase definition// if ((i2fcon1 == 1.0) and (i2fcon1 == int2float(3/2))) {setverdict(pass);} else {setverdict(fail, __LINE__);} //^In else statement// \ //^warning\: Control never reaches this code because of previous effective condition\(s\)// if ((i2fcon2 == -3.0) and (i2fcon2 == -3E0)) {setverdict(pass);} else {setverdict(fail, __LINE__);} //^In else statement// \ //^warning\: Control never reaches this code because of previous effective condition\(s\)// if ((i2fcon3 == 0.0) and (i2fcon3 == int2float(lengthof("")))) {setverdict(pass);} else {setverdict(fail, __LINE__);} //^In else statement// \ //^warning\: Control never reaches this code because of previous effective condition\(s\)// if ((i2fcon4 == 0.0) and (i2fcon4 == int2float(i2fconi[0]))) {setverdict(pass);} else {setverdict(fail, __LINE__);} //^In else statement// \ //^warning\: Control never reaches this code because of previous effective condition\(s\)// if ((i2fcon5 == 0.0) and (i2fcon5 == int2float(i2fconii[0]))) {setverdict(pass);} else {setverdict(fail, __LINE__);} //^In else statement// \ //^warning\: Control never reaches this code because of previous effective condition\(s\)// if ((i2fcon6 == 6.0) and (i2fcon6 == int2float(20/3))) {setverdict(pass);} else {setverdict(fail, __LINE__);} //^In else statement// \ //^warning\: Control never reaches this code because of previous effective condition\(s\)// if ((i2fcon7 == 2.0) and (i2fcon7 == int2float(8 mod 6))) {setverdict(pass);} else {setverdict(fail, __LINE__);} //^In else statement// \ //^warning\: Control never reaches this code because of previous effective condition\(s\)// if ((i2fcon8 == 2147483648.0) and (i2fcon8 == int2float(2147483648))) {setverdict(pass);} else {setverdict(fail, __LINE__);} //^In else statement// \ //^warning\: Control never reaches this code because of previous effective condition\(s\)// if ((i2fcon9 == 214748364800.0) and (i2fcon9 == int2float(214748364800))) {setverdict(pass);} else {setverdict(fail, __LINE__);} //^In else statement// \ //^warning\: Control never reaches this code because of previous effective condition\(s\)// if ((i2fcon10 == 4294967296.0) and (i2fcon10 == int2float(4294967296))) {setverdict(pass);} else {setverdict(fail, __LINE__);} //^In else statement// \ //^warning\: Control never reaches this code because of previous effective condition\(s\)// } /*--- INT2HEX --------------------------------------------------*/ const hexstring i2hcon := '0123456'H const hexstring i2hcon1 := int2hex(0,10) const hexstring i2hcon2 := int2hex(0,0) const hexstring i2hcon3 := int2hex(15,1) const hexstring i2hcon4 := int2hex(hex2int(i2hcon),lengthof(i2hcon)) const integer i2hconi := hex2int(i2hcon) const hexstring hs1 := '000000000000029D42B65689328BBE0C'H testcase int_to_hex() runs on PDTestComponent{ //In testcase definition// if ((i2hcon1 == '0000000000'H) and (i2hcon1 == int2hex(0,10))) {setverdict(pass);} else {setverdict(fail, __LINE__);} //^In else statement// \ //^warning\: Control never reaches this code because of previous effective condition\(s\)// if ((i2hcon2 == ''H) and (i2hcon2 == int2hex(0,0))) {setverdict(pass);} else {setverdict(fail, __LINE__);} //^In else statement// \ //^warning\: Control never reaches this code because of previous effective condition\(s\)// if ((i2hcon3 == 'F'H) and (i2hcon3 == int2hex(15,1))) {setverdict(pass);} else {setverdict(fail, __LINE__);} //^In else statement// \ //^warning\: Control never reaches this code because of previous effective condition\(s\)// if ((i2hcon4 == i2hcon) and (i2hcon4 == int2hex(hex2int(i2hcon),lengthof(i2hcon)))) {setverdict(pass);} else {setverdict(fail, __LINE__);} //^In else statement// \ //^warning\: Control never reaches this code because of previous effective condition\(s\)// if (int2hex(i1, 32) == hs1) { setverdict(pass) } else { setverdict(fail, __LINE__) } //^In else statement// \ //^warning\: Control never reaches this code because of previous effective condition\(s\)// if (int2hex(12345678910111213141516, 32) == '000000000000029D42B65689328BBE0C'H) { setverdict(pass) } else { setverdict(fail, __LINE__) } //^In else statement// \ //^warning\: Control never reaches this code because of previous effective condition\(s\)// if (int2hex(12345678910111213141516, 32) == hs1) { setverdict(pass) } else { setverdict(fail, __LINE__) } //^In else statement// \ //^warning\: Control never reaches this code because of previous effective condition\(s\)// if (int2hex(12345678910111213141516, 20) == '029D42B65689328BBE0C'H) { setverdict(pass) } else { setverdict(fail, __LINE__) } //^In else statement// \ //^warning\: Control never reaches this code because of previous effective condition\(s\)// } /*--- INT2OCT --------------------------------------------------*/ const octetstring i2ocon := '12345678'O const octetstring i2ocon1 := int2oct(0,10) const octetstring i2ocon2 := int2oct(0,0) const octetstring i2ocon3 := int2oct(15,1) const octetstring i2ocon4 := int2oct(oct2int(i2ocon),lengthof(i2ocon)) const octetstring i2ocon5 := int2oct(33,8); const integer i2oconi := oct2int(i2ocon) const octetstring os1 := '00000000000000000000000000000000000000000000029D42B65689328BBE0C'O testcase int_to_oct() runs on PDTestComponent{ //In testcase definition// if ((i2ocon1 == '00000000000000000000'O) and (i2ocon1 == int2oct(0,10))) {setverdict(pass);} else {setverdict(fail, __LINE__);} //^In else statement// \ //^warning\: Control never reaches this code because of previous effective condition\(s\)// if ((i2ocon2 == ''O)and (i2ocon2 == int2oct(0,0))) {setverdict(pass);} else {setverdict(fail, __LINE__);} //^In else statement// \ //^warning\: Control never reaches this code because of previous effective condition\(s\)// if ((i2ocon3 == '0F'O) and (i2ocon3 == int2oct(15,1))) {setverdict(pass);} else {setverdict(fail, __LINE__);} //^In else statement// \ //^warning\: Control never reaches this code because of previous effective condition\(s\)// if (i2ocon5 == '0000000000000021'O) {setverdict(pass);} else {setverdict(fail, __LINE__);} //^In else statement// \ //^warning\: Control never reaches this code because of previous effective condition\(s\)// if ((i2ocon4 == i2ocon) and (i2ocon4 == int2oct(oct2int(i2ocon),lengthof(i2ocon)))) {setverdict(pass);} else {setverdict(fail, __LINE__);} //^In else statement// \ //^warning\: Control never reaches this code because of previous effective condition\(s\)// if (int2oct(i1, 32) == os1) { setverdict(pass) } else { setverdict(fail, __LINE__) } //^In else statement// \ //^warning\: Control never reaches this code because of previous effective condition\(s\)// if (int2oct(12345678910111213141516, 32) == '00000000000000000000000000000000000000000000029D42B65689328BBE0C'O) { setverdict(pass) } else { setverdict(fail, __LINE__) } //^In else statement// \ //^warning\: Control never reaches this code because of previous effective condition\(s\)// if (int2oct(12345678910111213141516, 32) == os1) { setverdict(pass) } else { setverdict(fail, __LINE__) } //^In else statement// \ //^warning\: Control never reaches this code because of previous effective condition\(s\)// if (int2oct(12345678910111213141516, 10) == '029D42B65689328BBE0C'O) { setverdict(pass) } else { setverdict(fail, __LINE__) } //^In else statement// \ //^warning\: Control never reaches this code because of previous effective condition\(s\)// } /*--- INT2STR --------------------------------------------------*/ const charstring i2scon := "1234567890" const charstring i2scon1 := int2str(0) const charstring i2scon2 := int2str(-1) const charstring i2scon3 := int2str(16 mod 3) const charstring i2scon4 := int2str(16 rem 3) const charstring i2scon5 := int2str(lengthof(i2scon)) const integer i2sconi := str2int(i2scon) const charstring i2scon6 := int2str(i2sconi) const charstring i2scon7 := "1234567891011121314151617181920" const charstring i2scon8 := "-1234567891011121314151617181920" // Negative values. const integer i2sconi1 := str2int(i2scon7) const integer i2sconi2 := str2int(i2scon8) testcase int_to_str() runs on PDTestComponent{ //In testcase definition// if ((i2scon1 == "0") and (i2scon1 == int2str(0))) {setverdict(pass);} else {setverdict(fail, __LINE__);} //^In else statement// \ //^warning\: Control never reaches this code because of previous effective condition\(s\)// if ((i2scon2 == "-1") and (i2scon2 == int2str(-1))) {setverdict(pass);} else {setverdict(fail, __LINE__);} //^In else statement// \ //^warning\: Control never reaches this code because of previous effective condition\(s\)// if ((i2scon3 == "1") and (i2scon3 == int2str(16 mod 3))) {setverdict(pass);} else {setverdict(fail, __LINE__);} //^In else statement// \ //^warning\: Control never reaches this code because of previous effective condition\(s\)// if ((i2scon4 == "1") and (i2scon4 == int2str(16 rem 3))) {setverdict(pass);} else {setverdict(fail, __LINE__);} //^In else statement// \ //^warning\: Control never reaches this code because of previous effective condition\(s\)// if ((i2scon5 == "10") and (i2scon5 == int2str(lengthof(i2scon)))) {setverdict(pass);} else {setverdict(fail, __LINE__);} //^In else statement// \ //^warning\: Control never reaches this code because of previous effective condition\(s\)// if ((i2scon6 == i2scon) and (i2scon6 == int2str(i2sconi))) {setverdict(pass);} else {setverdict(fail, __LINE__);} //^In else statement// \ //^warning\: Control never reaches this code because of previous effective condition\(s\)// // Compile time evaluation. (Positive/negative.) if ((i2scon7 == int2str(1234567891011121314151617181920) and (int2str(1234567891011121314151617181920) == i2scon7))) {setverdict(pass);} else {setverdict(fail, __LINE__);} //^In else statement// \ //^warning\: Control never reaches this code because of previous effective condition\(s\)// if ((int2str(1234567891011121314151617181930 - 10) == i2scon7) and (i2scon7 == int2str(1234567891011121314151617181930 - 10))) {setverdict(pass);} else {setverdict(fail, __LINE__);} //^In else statement// \ //^warning\: Control never reaches this code because of previous effective condition\(s\)// if ((i2scon7 == int2str(i2sconi1) and (int2str(i2sconi1) == i2scon7))) {setverdict(pass);} else {setverdict(fail, __LINE__);} //^In else statement// \ //^warning\: Control never reaches this code because of previous effective condition\(s\)// if ((int2str(i2sconi1 + 10 - 10) == i2scon7) and (i2scon7 == int2str(i2sconi1 + 10 - 10))) {setverdict(pass);} else {setverdict(fail, __LINE__);} //^In else statement// \ //^warning\: Control never reaches this code because of previous effective condition\(s\)// if ((i2scon8 == int2str(-1234567891011121314151617181920) and (int2str(1234567891011121314151617181920) == i2scon7))) {setverdict(pass);} else {setverdict(fail, __LINE__);} //^In else statement// \ //^warning\: Control never reaches this code because of previous effective condition\(s\)// if ((int2str(-1234567891011121314151617181930 + 10) == i2scon8) and (i2scon8 == int2str(-1234567891011121314151617181930 + 10))) {setverdict(pass);} else {setverdict(fail, __LINE__);} //^In else statement// \ //^warning\: Control never reaches this code because of previous effective condition\(s\)// if ((i2scon8 == int2str(i2sconi2) and (int2str(i2sconi2) == i2scon8))) {setverdict(pass);} else {setverdict(fail, __LINE__);} //^In else statement// \ //^warning\: Control never reaches this code because of previous effective condition\(s\)// if ((int2str(i2sconi2 + 10 - 10) == i2scon8) and (i2scon8 == int2str(i2sconi2 + 10 - 10))) {setverdict(pass);} else {setverdict(fail, __LINE__);} //^In else statement// \ //^warning\: Control never reaches this code because of previous effective condition\(s\)// } control { execute (int_to_bit()); execute (int_to_char()); execute (int_to_unichar()); execute (int_to_float()); execute (int_to_hex()); execute (int_to_oct()); execute (int_to_str()); } }