blob: 5584cb0caf83de4fa0774a906ea8582b043d3bb5 [file] [log] [blame]
///////////////////////////////////////////////////////////////////////////////
// //
// Copyright (c) 2000-2017 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 //
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
// Module: HashMap_oct2int_test
//
// Purpose:
// Test file for HashMap.
//
//////////////////////////////////////////////////////////
module HashMap_oct2int_test
{
//=========================================================================
// Import Part
//=========================================================================
import from EPTF_CLL_Common_Definitions all;
import from EPTF_CLL_HashMapOct2Int_Functions all;
import from TCCEnv_Functions all;
import from EPTF_CLL_Base_Functions all;
import from EPTF_CLL_HashMap_Functions all;
import from EPTF_CLL_HashMap_Definitions all;
//=========================================================================
//Component Types
//=========================================================================
type component MyMTC_CT extends EPTF_HashMap_CT{
}
//=========================================================================
// Testcases
//=========================================================================
//=========================================================================
// Testcase: tc_oct2int_HashMap_baseFunctions()
//=========================================================================
testcase tc_oct2int_HashMap_baseFunctions()
runs on MyMTC_CT
{
f_EPTF_HashMap_init_CT ("HashMapTest");
var integer wrong_name_check;
if(not f_EPTF_oct2int_HashMap_GetID("badname",wrong_name_check) )
{
log("Wrong name, ID: ",wrong_name_check);
setverdict(pass);
}
//create first hashmap
var charstring first := "my_first_hashmap";
var integer first_int;
var integer first_check;
first_int := f_EPTF_oct2int_HashMap_New (first);
log("Creating first hashmap called: ", first, " ", first_int);
// getting the ID of first hashmap
log("Getting the ID of first hashmap");
if( f_EPTF_oct2int_HashMap_GetID(first,first_check) )
{
if ( first_int == first_check ){ setverdict(pass) } else { setverdict (fail) }
}
//create second hashmap
var charstring second := "my_second_hashmap";
var integer second_int;
var integer second_check;
second_int := f_EPTF_oct2int_HashMap_New (second);
log("Creating second hashmap called: ", second, " ", second_int);
// getting the ID of second hashmap
log("Getting the ID of second hashmap");
if( f_EPTF_oct2int_HashMap_GetID(second,second_check) )
{
if ( second_int == second_check ){ setverdict(pass) } else { setverdict (fail) }
}
//maximum size
var float hm_max_size;
hm_max_size := f_EPTF_oct2int_HashMap_MaxSize (first_int);
log( "Maximum size of hashmap first: ",hm_max_size );
//getting the number of buckets
var integer hm_bucketCount;
hm_bucketCount := f_EPTF_oct2int_HashMap_BucketCount (first_int);
/*log( "Size of the hashmap first before resizing: ",hm_bucketCount );
//setting the number of buckets to minimum 500
f_EPTF_oct2int_HashMap_Resize (first_int,500);
hm_bucketCount := f_EPTF_oct2int_HashMap_BucketCount (first_int);
log( "Size of the hashmap first after resizing: ",hm_bucketCount );
if ( hm_bucketCount >= 200){ setverdict(pass) } else { setverdict (fail) }*/
//insert to first hashmap
log( "Inserting data to hashmap first" );
f_EPTF_oct2int_HashMap_Insert ( first_int, '5A'O, 11 );
f_EPTF_oct2int_HashMap_Insert ( first_int, '6B10'O, 22 );
//print number of key/value pairs of first hashmap
var integer hm_size;
hm_size := f_EPTF_oct2int_HashMap_Size (first_int);
log( "Number of elements in hashmap first: \n", hm_size );
if ( hm_size == 2 ){ setverdict(pass) }else{ setverdict( fail ) }
// read an element from first hashmap
var integer hm_data;
if ( f_EPTF_oct2int_HashMap_Find ( first_int,'5A'O, hm_data ) )
{
log("Reading data from hashmap first, key = '5A'O data: \n", hm_data );
if ( hm_data == 11 ){ setverdict(pass) }else{ setverdict(fail) }
}
else
{
log("xxxxxxxxxx");
setverdict(fail);
}
//insert to second hashmap
log( "Inserting data to hashmap second" );
f_EPTF_oct2int_HashMap_Insert ( second_int, '5A'O, 11 );
f_EPTF_oct2int_HashMap_Insert ( second_int, '6B10'O, 33 );
f_EPTF_oct2int_HashMap_Insert ( second_int, '7C235D'O, 44 );
//print number of key/value pairs of second hashmap
var integer hm_size2;
hm_size2 := f_EPTF_oct2int_HashMap_Size (second_int);
log( "Number of elements in hashmap second: \n", hm_size2 );
if ( hm_size2 == 3 ){ setverdict(pass) }else{ setverdict(fail) }
// read an element from second hashmap
//var integer hm_data2;
if ( f_EPTF_oct2int_HashMap_Find ( second_int,'7C235D'O, hm_data ) )
{
log("Reading data from hashmap second, key = '5A'O data: \n", hm_data );
if ( hm_data == 44 ){ setverdict(pass) }else{ setverdict(fail) }
}
else
{
setverdict(fail);
}
// read a not valid element from first hashmap
var integer hm_data3;
if ( f_EPTF_oct2int_HashMap_Find ( first_int,'7891'O, hm_data3 ) )
{
setverdict(fail);
}
else
{
log("Reading data from hashmap first, key = '7891'O data: \n", hm_data3 );
setverdict(pass);
}
//erase an element from first
f_EPTF_oct2int_HashMap_Erase ( first_int, '5A'O );
hm_size := f_EPTF_oct2int_HashMap_Size (first_int);
log( "Number of elements in hashmap first: \n", hm_size );
if ( hm_size == 1 ){ setverdict(pass) }else{ setverdict(fail) }
//calculate hash value of a key
var integer hm_hashValue;
hm_hashValue := f_EPTF_oct2int_HashMap_CallHashFunc ( first_int,'A5'O );
log( "The hash value of key='5A'O is:", hm_hashValue );
hm_hashValue := f_EPTF_oct2int_HashMap_CallHashFunc ( first_int,'B510'O );
log( "The hash value of key='6B10'O is:", hm_hashValue );
//create third hashmap
var charstring third := "my_third_hashmap";
var integer third_int;
var integer third_check;
third_int := f_EPTF_oct2int_HashMap_New (third);
log("Creating third hashmap called: ", third, " ", third_int);
f_EPTF_oct2int_HashMap_Assign( third_int, first_int );
log("Assigning third hashmap to first");
f_EPTF_oct2int_HashMap_Insert ( first_int, '7C'O, 99 );
//erasing a key
f_EPTF_oct2int_HashMap_Erase ( first_int, '6B10'O );
//erasing a non existing key
f_EPTF_oct2int_HashMap_Erase ( first_int, '999999'O );
// Dumping all hashmap
f_EPTF_oct2int_HashMap_DumpAll();
//The contents of all hashmap:
//----Dumping all begin----
//----Dumping HashMap called: "my_first_hashmap" begin----
//(key,data): "7C235D" 44
//(key,data): "5A" 11
//(key,data): "7C" 99
//----Dumping HashMap called: "my_first_hashmap" end----
//----Dumping HashMap called: "my_second_hashmap" begin----
//(key,data): "6B10" 22
//----Dumping HashMap called: "my_second_hashmap" end----
//----Dumping HashMap called: "my_third_hashmap" begin----
//(key,data): "7C235D" 44
//(key,data): "6B10" 33
//(key,data): "5A" 11
//----Dumping HashMap called: "my_third_hashmap" end----
//----Dumping all end----
//clear the hashmap first
log( "Clearing hashmap and checking whether it`s empty: \n");
f_EPTF_oct2int_HashMap_Clear(first_int);
//check if hashmap is empty
if( f_EPTF_oct2int_HashMap_Empty(first_int) ){setverdict(pass) } else { setverdict (fail) }
//deleting hashmaps
f_EPTF_oct2int_HashMap_Delete (first);
log("Deleting first hashmap called: ",first);
f_EPTF_oct2int_HashMap_Delete (third);
log("Deleting third hashmap called: ",third);
f_EPTF_oct2int_HashMap_Delete (second);
log("Deleting second hashmap called: ",second);
//create a fourth hashmap
var charstring fourth := "my_fourth_hashmap";
var integer fourth_int;
var integer fourth_check;
fourth_int := f_EPTF_oct2int_HashMap_New (fourth);
log("Creating fourth hashmap called: ", fourth, " ", fourth_int);
f_EPTF_oct2int_HashMap_Delete (fourth);
log("Deleting fourth hashmap called: ",fourth);
// DeleteByID test:
var charstring hashMap_1 := "my_hashMap_1_hashmap"
var integer hashMap_1_Id := f_EPTF_oct2int_HashMap_New (hashMap_1);
var charstring hashMap_2 := "my_hashMap_2_hashmap"
var integer hashMap_2_Id := f_EPTF_oct2int_HashMap_New (hashMap_2);
var charstring hashMap_3 := "my_hashMap_3_hashmap"
var integer hashMap_3_Id := f_EPTF_oct2int_HashMap_New (hashMap_3);
f_EPTF_oct2int_HashMap_Insert ( hashMap_1_Id,'1230'O , 11 )
f_EPTF_oct2int_HashMap_Insert ( hashMap_2_Id,'2210'O , 21 )
f_EPTF_oct2int_HashMap_Insert ( hashMap_2_Id,'2220'O , 22 )
f_EPTF_oct2int_HashMap_Insert ( hashMap_3_Id,'3210'O , 31 )
f_EPTF_oct2int_HashMap_Insert ( hashMap_3_Id,'3220'O , 32 )
f_EPTF_oct2int_HashMap_Insert ( hashMap_3_Id,'3230'O , 33 )
if (not f_EPTF_oct2int_HashMap_Find ( hashMap_1_Id,'1230'O , hm_data ) and hm_data != 11) {
setverdict(fail, "Existing element not found")
};
if (not f_EPTF_oct2int_HashMap_Find ( hashMap_2_Id,'2210'O , hm_data ) and hm_data != 21) {
setverdict(fail, "Existing element not found")
};
if (not f_EPTF_oct2int_HashMap_Find ( hashMap_2_Id,'2220'O , hm_data ) and hm_data != 22) {
setverdict(fail, "Existing element not found")
};
if (not f_EPTF_oct2int_HashMap_Find ( hashMap_3_Id,'3210'O , hm_data ) and hm_data != 31) {
setverdict(fail, "Existing element not found")
};
if (not f_EPTF_oct2int_HashMap_Find ( hashMap_3_Id,'3220'O , hm_data ) and hm_data != 32) {
setverdict(fail, "Existing element not found")
};
if (not f_EPTF_oct2int_HashMap_Find ( hashMap_3_Id,'3230'O , hm_data ) and hm_data != 33) {
setverdict(fail, "Existing element not found")
};
if (f_EPTF_oct2int_HashMap_Find ( hashMap_2_Id,'3230'O , hm_data )) {
setverdict(fail, "Nonexistent element found")
};
f_EPTF_oct2int_HashMap_DumpAll();
f_EPTF_oct2int_HashMap_DeleteById (hashMap_2_Id);
f_EPTF_oct2int_HashMap_DumpAll();
if (not f_EPTF_oct2int_HashMap_Find ( hashMap_1_Id,'1230'O , hm_data ) and hm_data != 11) {
setverdict(fail, "Existing element not found")
};
if (not f_EPTF_oct2int_HashMap_Find ( hashMap_3_Id,'3210'O , hm_data ) and hm_data != 31) {
setverdict(fail, "Existing element not found")
};
if (not f_EPTF_oct2int_HashMap_Find ( hashMap_3_Id,'3220'O , hm_data ) and hm_data != 32) {
setverdict(fail, "Existing element not found")
};
if (not f_EPTF_oct2int_HashMap_Find ( hashMap_3_Id,'3230'O , hm_data ) and hm_data != 33) {
setverdict(fail, "Existing element not found")
};
var integer id;
if( f_EPTF_oct2int_HashMap_GetID(hashMap_2,id) ) {
setverdict(fail, "Nonexistent hashmap found");
}
if(not f_EPTF_oct2int_HashMap_GetID(hashMap_1,id) and id != hashMap_1_Id ) {
setverdict(fail, "Existent hashmap not found");
}
if(not f_EPTF_oct2int_HashMap_GetID(hashMap_3,id) and id != hashMap_3_Id ) {
setverdict(fail, "Existent hashmap not found");
}
// if (f_EPTF_oct2int_HashMap_Find ( hashMap_2_Id,221 , hm_data )) {
// setverdict(fail, "Nonexistent element found")
// };
//
f_EPTF_oct2int_HashMap_Delete (hashMap_2);
f_EPTF_oct2int_HashMap_DeleteById (hashMap_2_Id);
f_EPTF_oct2int_HashMap_DeleteById (hashMap_1_Id);
f_EPTF_oct2int_HashMap_DeleteById (hashMap_1_Id);
f_EPTF_oct2int_HashMap_Delete (hashMap_1);
f_EPTF_oct2int_HashMap_DeleteById (hashMap_3_Id);
f_EPTF_oct2int_HashMap_DeleteById (hashMap_3_Id);
f_EPTF_oct2int_HashMap_DumpAll();
// DeleteByID test END
f_EPTF_Base_stop(none);
}
//=========================================================================
// Testcase: tc_oct2int_HashMap_test_bigIntData()
//=========================================================================
testcase tc_oct2int_HashMap_test_bigIntData()
runs on MyMTC_CT
{
f_EPTF_HashMap_init_CT ("tc_oct2int_HashMap_test_bigIntData");
var integer vl_hashMapId := f_EPTF_oct2int_HashMap_New ("HM1");
f_EPTF_oct2int_HashMap_Insert ( vl_hashMapId,'10'O , 12345678901234567890 );
var integer vl_data;
if (not f_EPTF_oct2int_HashMap_Find ( vl_hashMapId,'10'O , vl_data ) and vl_data != 12345678901234567890) {
setverdict(fail, "Existing element not found")
};
f_EPTF_Base_stop(pass);
}
//=========================================================================
// Testcase: tc_oct2int_HashMap_otherFunctions()
//=========================================================================
testcase tc_oct2int_HashMap_otherFunctions()
runs on MyMTC_CT
{
f_EPTF_HashMap_init_CT ("HashMapTest");
//create a hashmap
var charstring first := "my_hashmap";
var integer first_int;
var integer first_check;
first_int := f_EPTF_oct2int_HashMap_New (first);
// getting the ID of hashmap
log("Getting the ID of hashmap");
if( f_EPTF_oct2int_HashMap_GetID(first,first_check) )
{
if ( first_int == first_check ){ setverdict(pass) } else { setverdict (fail) }
}
log("Creating hashmap called: ", first, " ", first_int);
var integer x;
x := f_EPTF_oct2int_HashMap_Size (first_int);
log( "Number of elements in hashmap: \n", x);
// 1. While cycle, no elements in hashmap
var octetstring readkey:=''O;
log("1. WHILE cycle, no elements in hashmap ");
var boolean cycleIsOver:= f_EPTF_oct2int_HashMap_Begin(first_int, readkey);
if( not cycleIsOver )
{
log("No elements in hashmap" );
setverdict(pass);
};
while (cycleIsOver)
{
var integer hm_data;
if ( f_EPTF_oct2int_HashMap_Find ( first_int, readkey, hm_data ) )
{
log("1. WHILE cycle: \n", readkey," ", hm_data );
}
cycleIsOver := f_EPTF_oct2int_HashMap_Next(first_int,readkey);
setverdict(fail);
}
f_EPTF_oct2int_HashMap_Insert ( first_int, 'A478'O, 11 );
x := f_EPTF_oct2int_HashMap_Size (first_int);
log( "Number of elements in hashmap: \n", x);
// 2. While cycle, one element in hashmap
log("2. WHILE cycle, 1 element in hashmap ");
readkey:=''O;
cycleIsOver:= f_EPTF_oct2int_HashMap_Begin(first_int, readkey);
if( not cycleIsOver )
{
log("No elements in hashmap" );
setverdict(fail);
};
while (cycleIsOver)
{
var integer hm_data;
if ( f_EPTF_oct2int_HashMap_Find ( first_int, readkey, hm_data ) )
{
log("2. WHILE cycle: \n", readkey," ", hm_data );
}
cycleIsOver := f_EPTF_oct2int_HashMap_Next(first_int,readkey);
setverdict(pass);
}
f_EPTF_oct2int_HashMap_Insert ( first_int, '451362'O, 22 );
x := f_EPTF_oct2int_HashMap_Size (first_int);
log( "Number of elements in hashmap: \n", x);
// 3. While cycle, two element in hashmap
log("3. WHILE cycle, 2 element in hashmap ");
readkey:=''O;
cycleIsOver:= f_EPTF_oct2int_HashMap_Begin(first_int, readkey);
if( not cycleIsOver )
{
log("No elements in hashmap" );
setverdict(fail);
};
while (cycleIsOver)
{
var integer hm_data;
if ( f_EPTF_oct2int_HashMap_Find ( first_int, readkey, hm_data ) )
{
log("3. WHILE cycle: \n", readkey," ", hm_data );
}
cycleIsOver := f_EPTF_oct2int_HashMap_Next(first_int,readkey);
setverdict(pass);
}
f_EPTF_oct2int_HashMap_Insert ( first_int,'5F233E'O, 33 );
var octetstring gg := ''O;
f_EPTF_oct2int_HashMap_Insert ( first_int, gg, 44 );
// 4. While cycle, four element in hashmap
log("4. WHILE cycle, 4 element in hashmap ");
readkey:=''O;
cycleIsOver:= f_EPTF_oct2int_HashMap_Begin(first_int, readkey);
if( not cycleIsOver )
{
log("No elements in hashmap" );
setverdict(fail);
};
while (cycleIsOver)
{
var integer hm_data;
if ( f_EPTF_oct2int_HashMap_Find ( first_int, readkey, hm_data ) )
{
log("4. WHILE cycle: \n", readkey," ", hm_data );
}
cycleIsOver := f_EPTF_oct2int_HashMap_Next(first_int,readkey);
setverdict(pass);
}
// FOR cycle, four elements in hashmap
log("FOR cycle, 4 element in hashmap ");
readkey:=''O;
for (var boolean cycle:=f_EPTF_oct2int_HashMap_Begin(first_int, readkey);
cycle; cycle:=f_EPTF_oct2int_HashMap_Next(first_int,readkey))
{
var integer hm_data;
if ( f_EPTF_oct2int_HashMap_Find ( first_int, readkey, hm_data ) )
{
log("FOR cycle: \n", readkey, " ", hm_data );
}
setverdict(pass);
}
// Dumping hashmap
log("Dumping hashmap by name");
f_EPTF_oct2int_HashMap_Dump(first);
// Dumping hashmap by id
log("Dumping hashmap by ID");
f_EPTF_oct2int_HashMap_DumpByID(first_int);
//deleting hashmap
f_EPTF_oct2int_HashMap_Delete (first);
log("Deleting hashmap called: ",first);
f_EPTF_Base_stop(none);
}
//=========================================================================
// Testcase: tc_oct2int_HashMap_testUpdateFunction()
//=========================================================================
testcase tc_oct2int_HashMap_testUpdateFunction()
runs on MyMTC_CT
{
f_EPTF_HashMap_init_CT ("HashMapTest");
//create hashmap
var charstring first := "my_hashmap";
var integer first_int;
var integer first_check;
first_int := f_EPTF_oct2int_HashMap_New (first);
log("Creating hashmap called: ", first, " ", first_int);
//insert to hashmap
log( "Inserting data to hashmap" );
f_EPTF_oct2int_HashMap_Insert ( first_int,'5A'O , 11 );
//
f_EPTF_oct2int_HashMap_Update ( first_int,'5A'O , 22 );
f_EPTF_oct2int_HashMap_Update ( first_int,'6B10'O , 33 );
f_EPTF_oct2int_HashMap_Update ( first_int,'7C235D'O , 44 );
// read an element from hashmap
var integer hm_data;
if ( f_EPTF_oct2int_HashMap_Find ( first_int,'5A'O , hm_data ) )
{
log("Reading data from hashmap, key = '5A'O data: \n", hm_data );
if ( hm_data == 22 ){ setverdict(pass) }else{ setverdict(fail) }
}
else
{
setverdict(fail);
}
// Dumping hashmap
log("Dumping hashmap ");
f_EPTF_oct2int_HashMap_Dump(first);
//deleting hashmaps
f_EPTF_oct2int_HashMap_Delete (first);
log("Deleting hashmap called: ",first);
f_EPTF_Base_stop(none);
}
function f_oct2int_HashMap_createOfSize(
in integer pl_size)
runs on MyMTC_CT
{
var integer i := 0;
var charstring name := "my_hashmap";
var integer id := f_EPTF_oct2int_HashMap_New(name);
for(i := 0; i < pl_size; i := i + 1) {
f_EPTF_oct2int_HashMap_Insert(id, int2oct(i,4), i);
}
f_EPTF_oct2int_HashMap_Delete(name);
}
//=========================================================================
// Testcase: tc_oct2int_HashMap_testGrowage()
//=========================================================================
testcase tc_oct2int_HashMap_testGrowage()
runs on MyMTC_CT
{
f_EPTF_HashMap_init_CT ("HashMapTest");
if(tsp_CLL_debug_acceptableMaxSizeOfGrowingVariables < 0) {
log(%definitionId&": tsp_CLL_debug_acceptableMaxSizeOfGrowingVariables is less than 0.");
stop;
}
log(%definitionId&": Creating a hashmap with ", tsp_CLL_debug_acceptableMaxSizeOfGrowingVariables, " elements");
log(%definitionId&": This should cause NO logs about exceeding the max size.");
f_oct2int_HashMap_createOfSize(tsp_CLL_debug_acceptableMaxSizeOfGrowingVariables);
log(%definitionId&": Creating a hashmap with ", tsp_CLL_debug_acceptableMaxSizeOfGrowingVariables + 1, " elements");
log(%definitionId&": This should cause a single log about exceeding the max size.");
f_oct2int_HashMap_createOfSize(tsp_CLL_debug_acceptableMaxSizeOfGrowingVariables + 1);
if(tsp_CLL_debug_acceptableMaxSizeOfGrowingVariables > 0) {
log(%definitionId&": Creating a hashmap with ", 2*tsp_CLL_debug_acceptableMaxSizeOfGrowingVariables, " elements");
log(%definitionId&": This should cause a few logs about exceeding the max size.")
f_oct2int_HashMap_createOfSize(2 * tsp_CLL_debug_acceptableMaxSizeOfGrowingVariables);
log(%definitionId&": Creating a hashmap with ", 100*tsp_CLL_debug_acceptableMaxSizeOfGrowingVariables, " elements");
log(%definitionId&": This should cause more logs about exceeding the max size.")
f_oct2int_HashMap_createOfSize(100 * tsp_CLL_debug_acceptableMaxSizeOfGrowingVariables);
}
f_EPTF_Base_stop(none);
}
//=========================================================================
// Testcase: tc_oct2int_HashMap_FindTest()
//=========================================================================
testcase tc_oct2int_HashMap_FindTest()
runs on MyMTC_CT
{
f_EPTF_HashMap_init_CT ("HashMapTest");
var integer vl_i := -3;
var integer vl_h := f_EPTF_oct2int_HashMap_New("bubuhash");
f_EPTF_oct2int_HashMap_Insert(vl_h, '5A'O, 1);
f_EPTF_oct2int_HashMap_Insert(vl_h, '6B10'O, 2);
var boolean vl_ret := f_EPTF_oct2int_HashMap_Find(vl_h, '7C235D'O, vl_i);
if(vl_i == -1 and not vl_ret){
setverdict(pass)
}else{
setverdict ( fail );
}
vl_ret := f_EPTF_oct2int_HashMap_Find(vl_h, '6B10'O, vl_i);
if(vl_i != 2 or not vl_ret){
setverdict ( fail );
}
vl_ret := f_EPTF_oct2int_HashMap_Find(vl_h, '5A'O, vl_i);
if(vl_i != 1 or not vl_ret){
setverdict ( fail );
}
f_EPTF_oct2int_HashMap_Delete("bubuhash");
f_EPTF_Base_stop(none);
}
///////////////////////////////////////////////////////////
// Testcase: tc_oct2int_HashMap_NoCleanUp1 and 2
//
// Purpose:
// To test the Hashmap init function : the first test case inits a hashmap
// and exists without calling the cleanup.
// The second one is the one to watch. If it passes, then the feature is ok.
// It tries to create a hashmap and insert a data just like the first
// traffic case. If the init and cleanup works fine, it will succeed.
// If error, then the cleanup does not erase the hashmaps created in
// the previous testcases if no cleanup is called (if e.g. a DTE happens).
//
///////////////////////////////////////////////////////////
testcase tc_oct2int_HashMap_NoCleanUp1() runs on MyMTC_CT
{
f_EPTF_HashMap_init_CT ("HashMapTest");
var integer vl_h := f_EPTF_oct2int_HashMap_New("bubuhash");
f_EPTF_oct2int_HashMap_Insert(vl_h, '5A'O, 1);
setverdict(pass);
}
testcase tc_oct2int_HashMap_NoCleanUp2() runs on MyMTC_CT
{
f_EPTF_HashMap_init_CT ("HashMapTest");
var integer vl_h := f_EPTF_oct2int_HashMap_New("bubuhash");
f_EPTF_oct2int_HashMap_Insert(vl_h, '5A'O, 1);
setverdict(pass);
f_EPTF_Base_cleanup_CT();
f_EPTF_Base_stop(none);
}
//=========================================================================
// Testcase: tc_oct2int_HashMapTest_dumpByID_manual()
//=========================================================================
testcase tc_oct2int_HashMapTest_dumpByID_manual()
runs on MyMTC_CT
{
f_EPTF_HashMap_init_CT ("HashMapTest_dump");
//create first hashmap
var charstring first := "my_first_hashmap";
var integer first_int;
first_int := f_EPTF_oct2int_HashMap_New (first);
f_EPTF_oct2int_HashMap_Insert ( first_int,'1123'O , 111 );
f_EPTF_oct2int_HashMap_Insert ( first_int,'1234'O , 122 );
f_EPTF_oct2int_HashMap_Insert ( first_int,'1345'O , 133 );
f_EPTF_oct2int_HashMap_Insert ( first_int,'1456'O , 144 );
//create second hashmap
var charstring second := "my_second_hashmap";
var integer second_int;
second_int := f_EPTF_oct2int_HashMap_New (second);
f_EPTF_oct2int_HashMap_Insert ( second_int,'2123'O , 211 );
f_EPTF_oct2int_HashMap_Insert ( second_int,'2234'O , 222 );
f_EPTF_oct2int_HashMap_Insert ( second_int,'2345'O , 233 );
f_EPTF_oct2int_HashMap_Insert ( second_int,'2456'O , 244 );
// Dumping hashmap
log("Dumping hashmap by name");
f_EPTF_oct2int_HashMap_Dump(first);
// Dumping hashmap by id
log("Dumping hashmap by ID");
f_EPTF_oct2int_HashMap_DumpByID(first_int);
// Dumping hashmap
log("Dumping hashmap by name");
f_EPTF_oct2int_HashMap_Dump(second);
// Dumping hashmap by id
log("Dumping hashmap by ID");
f_EPTF_oct2int_HashMap_DumpByID(second_int);
// Dumping all hashmap
f_EPTF_oct2int_HashMap_DumpAll();
//deleting hashmap
f_EPTF_oct2int_HashMap_Delete (first);
log("Deleting hashmap called: ",first);
//deleting hashmap
f_EPTF_oct2int_HashMap_Delete (second);
log("Deleting hashmap called: ",second);
f_EPTF_Base_stop(pass);
}
//=========================================================================
// Control
//=========================================================================
control
{
select (f_GetEnv("TTCN_TEST_TYPE")) {
case ("SMOKE") {
execute( tc_oct2int_HashMap_baseFunctions() );
execute(tc_oct2int_HashMap_test_bigIntData());
execute( tc_oct2int_HashMap_otherFunctions() );
execute( tc_oct2int_HashMap_testUpdateFunction() );
//execute( tc_oct2int_HashMap_testGrowage() );
execute( tc_oct2int_HashMap_FindTest() );
}
case else {
execute( tc_oct2int_HashMap_baseFunctions() );
execute(tc_oct2int_HashMap_test_bigIntData());
execute( tc_oct2int_HashMap_otherFunctions() );
execute( tc_oct2int_HashMap_testUpdateFunction() );
//execute( tc_oct2int_HashMap_testGrowage() );
execute( tc_oct2int_HashMap_FindTest() );
execute( tc_oct2int_HashMap_NoCleanUp1() );
execute( tc_oct2int_HashMap_NoCleanUp2() );
execute( tc_oct2int_HashMapTest_dumpByID_manual() );
}
}
}
} // end of module