Add unit test suite for trickTypeCharString(). (#1467)

* Add unit test suite for trickTypeCharString().

* Rewrite MM test Makefile, Address type warnings in tests.

* Fix test target in Makefile
This commit is contained in:
jmpenn 2023-04-05 15:28:14 -05:00 committed by GitHub
parent fc8eb338f1
commit 1b0def8886
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 339 additions and 292 deletions

View File

@ -55,7 +55,7 @@ void validate_temp_sequence (Trick::MemoryManager * memmgr, std::string object_n
EXPECT_EQ(data_ref->attr->num_index, 1);
ASSERT_EQ(data_ref->attr->index[0].size, expected_data.size());
for (int i = 0; i < expected_data.size(); i++) {
for (unsigned int i = 0; i < expected_data.size(); i++) {
EXPECT_EQ(data[i], expected_data[i]);
}
@ -71,7 +71,7 @@ void validate_links_sequences (Trick::MemoryManager * memmgr, std::string object
std::string * data = (std::string *) data_ref->address;
ASSERT_EQ(data_ref->attr->index[0].size, lengths.size());
for (int i = 0; i < lengths.size(); i++) {
for (unsigned int i = 0; i < lengths.size(); i++) {
std::string inner_name = temp_name + "_" + std::to_string(i);
EXPECT_EQ(inner_name, data[i]);
REF2 * ref = memmgr->ref_attributes(inner_name.c_str());
@ -121,7 +121,7 @@ void validate_temp_set (Trick::MemoryManager * memmgr, std::string object_name,
ASSERT_EQ(data_ref->attr->index[0].size, expected_data.size());
std::set<T> reconstructed;
for (int i = 0; i < expected_data.size(); i++) {
for (unsigned int i = 0; i < expected_data.size(); i++) {
reconstructed.insert(data[i]);
}
@ -187,7 +187,7 @@ void validate_temp_map (Trick::MemoryManager * memmgr, std::string object_name,
// Lazy way - make a set of all the keys that were accessed in our expected
// map, and make sure that the size is the same.
std::set <Key> keySet;
for (int i = 0; i < expected_data.size(); i++) {
for (unsigned int i = 0; i < expected_data.size(); i++) {
Key k = keys_data[i];
Val v = vals_data[i];
@ -216,7 +216,7 @@ TEST_F(MM_stl_checkpoint, i_vec ) {
std::vector<int> test_data = get_test_data<int>(10);
// Prepare the STL to be tested
for (int i = 0; i < test_data.size(); i++) {
for (unsigned int i = 0; i < test_data.size(); i++) {
testbed->i_vec.push_back(test_data[i]);
}
@ -246,7 +246,7 @@ TEST_F(MM_stl_checkpoint, i_s_vec ) {
// Call the checkpoint function that is being tested
(vec_attr->checkpoint_stl)((void *) &testbed->i_s_vec, "my_alloc", vec_attr->name) ;
for (int i = 0; i < test_data.size(); i++) {
for (unsigned int i = 0; i < test_data.size(); i++) {
std::string var_name = "i_s_vec_" + std::to_string(i);
validate_temp_sequence<int>(memmgr, std::string("my_alloc"), var_name, test_data[i]);
}
@ -260,7 +260,7 @@ TEST_F(MM_stl_checkpoint, string_vec ) {
STLTestbed * testbed = (STLTestbed *) memmgr->declare_var("STLTestbed my_alloc");
std::vector<std::string> test_data = get_test_data<std::string>(20);
for (int i = 0; i < test_data.size(); i++) {
for (unsigned int i = 0; i < test_data.size(); i++) {
testbed->string_vec.emplace_back(test_data[i]);
}
@ -281,7 +281,7 @@ TEST_F(MM_stl_checkpoint, s_vec ) {
STLTestbed * testbed = (STLTestbed *) memmgr->declare_var("STLTestbed my_alloc");
std::vector<int> test_data = get_test_data<int>(20);
for (int i = 0; i < test_data.size(); i+=2) {
for (unsigned int i = 0; i < test_data.size(); i+=2) {
testbed->s_vec.emplace_back(test_data[i], test_data[i+1]);
}
@ -292,7 +292,7 @@ TEST_F(MM_stl_checkpoint, s_vec ) {
(vec_attr->checkpoint_stl)((void *) &testbed->s_vec, "my_alloc", vec_attr->name) ;
// ASSERT
for (int i = 0; i < test_data.size()/2; i++) {
for (unsigned int i = 0; i < test_data.size()/2; i++) {
std::string var_name = "s_vec_" + std::to_string(i);
validate_temp_pair<int, int>(memmgr, std::string("my_alloc"), var_name, std::pair<int,int>(test_data[i*2], test_data[i*2+1]));
}
@ -434,7 +434,7 @@ TEST_F(MM_stl_checkpoint, i_i_map ) {
std::vector<double> test_vals = get_test_data<double>(20);
std::map<int, double> test_map;
for (int i = 0; i < test_keys.size(); i++) {
for (unsigned int i = 0; i < test_keys.size(); i++) {
test_map[test_keys[i]] = test_vals[i];
testbed->i_i_map[test_keys[i]] = test_vals[i];
}
@ -460,7 +460,7 @@ TEST_F(MM_stl_checkpoint, i_s_map ) {
int start_index = 0;
std::vector<int> lengths = {7, 1, 12};
for (int i = 0; i < lengths.size(); i++) {
for (unsigned int i = 0; i < lengths.size(); i++) {
for (int j = 0; j < lengths[i]; j++) {
testbed->i_s_map[test_keys[i]].push(test_strings[start_index + j]);
test_map[test_keys[i]].push(test_strings[start_index + j]);
@ -508,7 +508,7 @@ TEST_F(MM_stl_checkpoint, s_i_map ) {
std::vector<int> lengths = {7, 1, 12};
int start_index = 0;
for (int i = 0; i < lengths.size(); i++) {
for (unsigned int i = 0; i < lengths.size(); i++) {
test_map[std::set<int>(test_keys.begin()+start_index, test_keys.begin()+start_index+lengths[i])] = test_vals[i];
testbed->s_i_map[std::set<int>(test_keys.begin()+start_index, test_keys.begin()+start_index+lengths[i])] = test_vals[i];
start_index += lengths[i];
@ -591,7 +591,7 @@ TEST_F(MM_stl_checkpoint, i_queue ) {
std::vector<int> test_data = get_test_data<int>(10);
// Prepare the STL to be tested
for (int i = 0; i < test_data.size(); i++) {
for (unsigned int i = 0; i < test_data.size(); i++) {
testbed->i_queue.push(test_data[i]);
}
@ -614,7 +614,7 @@ TEST_F(MM_stl_checkpoint, s_queue ) {
std::vector<double> test_second = get_test_data<double>(10);
// Prepare the STL to be tested
for (int i = 0; i < test_first.size(); i++) {
for (unsigned int i = 0; i < test_first.size(); i++) {
testbed->s_queue.push(std::pair<int,double>(test_first[i], test_second[i]));
}
@ -625,7 +625,7 @@ TEST_F(MM_stl_checkpoint, s_queue ) {
(vec_attr->checkpoint_stl)((void *) &testbed->s_queue, "my_alloc", vec_attr->name) ;
// ASSERT
for (int i = 0; i < test_first.size(); i++) {
for (unsigned int i = 0; i < test_first.size(); i++) {
std::string var_name = "s_queue_" + std::to_string(i);
validate_temp_pair(memmgr, std::string("my_alloc"), var_name, std::pair<int,double>(test_first[i], test_second[i]));
}
@ -643,7 +643,7 @@ TEST_F(MM_stl_checkpoint, nested_list_queue ) {
// Prepare the STL to be tested
int data_index = 0;
for (int i = 0; i < list_sizes.size(); i++) {
for (unsigned int i = 0; i < list_sizes.size(); i++) {
testbed->nested_list_queue.push(std::list<float>(test_data.begin() + data_index, test_data.begin() + data_index + list_sizes[i]));
data_index += list_sizes[i];
}
@ -656,7 +656,7 @@ TEST_F(MM_stl_checkpoint, nested_list_queue ) {
// ASSERT
data_index = 0;
for (int i = 0; i < list_sizes.size(); i++) {
for (unsigned int i = 0; i < list_sizes.size(); i++) {
std::string var_name = "nested_list_queue_" + std::to_string(i);
validate_temp_sequence(memmgr, std::string("my_alloc"), var_name, std::vector<float>(test_data.begin() + data_index, test_data.begin() + data_index + list_sizes[i]));
data_index += list_sizes[i];
@ -677,7 +677,7 @@ TEST_F(MM_stl_checkpoint, i_stack ) {
std::vector<long long> test_data = get_test_data<long long>(10);
// Prepare the STL to be tested
for (int i = 0; i < test_data.size(); i++) {
for (unsigned int i = 0; i < test_data.size(); i++) {
testbed->i_stack.push(test_data[i]);
}
@ -701,7 +701,7 @@ TEST_F(MM_stl_checkpoint, s_stack ) {
std::vector<double> test_second = get_test_data<double>(10);
// Prepare the STL to be tested
for (int i = 0; i < test_first.size(); i++) {
for (unsigned int i = 0; i < test_first.size(); i++) {
testbed->s_stack.push(std::pair<short,double>(test_first[i], test_second[i]));
}
@ -712,7 +712,7 @@ TEST_F(MM_stl_checkpoint, s_stack ) {
(vec_attr->checkpoint_stl)((void *) &testbed->s_stack, "my_alloc", vec_attr->name) ;
// ASSERT
for (int i = 0; i < test_first.size(); i++) {
for (unsigned int i = 0; i < test_first.size(); i++) {
std::string var_name = "s_stack_" + std::to_string(i);
// data in reverse order
validate_temp_pair(memmgr, std::string("my_alloc"), var_name, std::pair<short,double>(test_first[test_first.size()-1-i], test_second[test_first.size()-1-i]));
@ -732,7 +732,7 @@ TEST_F(MM_stl_checkpoint, nested_list_stack ) {
// Prepare the STL to be tested
int data_index = 0;
for (int i = 0; i < list_sizes.size(); i++) {
for (unsigned int i = 0; i < list_sizes.size(); i++) {
testbed->nested_list_stack.push(std::list<float>(test_data.begin() + data_index, test_data.begin() + data_index + list_sizes[i]));
data_index += list_sizes[i];
}
@ -745,7 +745,7 @@ TEST_F(MM_stl_checkpoint, nested_list_stack ) {
// ASSERT
data_index = 0;
for (int i = 0; i < list_sizes.size(); i++) {
for (unsigned int i = 0; i < list_sizes.size(); i++) {
// reverse data - just go through the lists backwards
std::string var_name = "nested_list_stack_" + std::to_string(list_sizes.size()-1-i);
validate_temp_sequence(memmgr, std::string("my_alloc"), var_name, std::vector<float>(test_data.begin() + data_index, test_data.begin() + data_index + list_sizes[i]));
@ -765,7 +765,7 @@ TEST_F(MM_stl_checkpoint, i_set ) {
std::vector<char> test_data = get_test_data<char>(1000);
// Prepare the STL to be tested
for (int i = 0; i < test_data.size(); i++) {
for (unsigned int i = 0; i < test_data.size(); i++) {
testbed->i_set.insert(test_data[i]);
}
@ -790,7 +790,7 @@ TEST_F(MM_stl_checkpoint, vector_set ) {
std::set<std::vector<int>> expected_data;
// Prepare the STL to be tested
int start_index = 0;
for (int i = 0; i < sizes.size(); i++) {
for (unsigned int i = 0; i < sizes.size(); i++) {
std::vector<int> temp_vec;
for (int j = 0; j < sizes[i]; j++) {
temp_vec.push_back(test_data[start_index+j]);
@ -831,7 +831,7 @@ TEST_F(MM_stl_checkpoint, s_set ) {
std::set<std::pair<int,int>> expected;
// Prepare the STL to be tested
for (int i = 0; i < test_first.size(); i++) {
for (unsigned int i = 0; i < test_first.size(); i++) {
testbed->s_set.insert(std::pair<int,int>(test_first[i], test_second[i]));
expected.insert(std::pair<int,int>(test_first[i], test_second[i]));
}
@ -902,7 +902,7 @@ TEST_F(MM_stl_checkpoint, i_multiset ) {
std::multiset<int> expected;
// Prepare the STL to be tested
for (int i = 0; i < test_data.size(); i++) {
for (unsigned int i = 0; i < test_data.size(); i++) {
testbed->i_multiset.insert(test_data[i]);
testbed->i_multiset.insert(test_data[i]);
expected.insert(test_data[i]);
@ -930,7 +930,7 @@ TEST_F(MM_stl_checkpoint, vector_multiset ) {
std::multiset<std::vector<int>> expected_data;
// Prepare the STL to be tested
int start_index = 0;
for (int i = 0; i < sizes.size(); i++) {
for (unsigned int i = 0; i < sizes.size(); i++) {
std::vector<int> temp_vec;
for (int j = 0; j < sizes[i]; j++) {
temp_vec.push_back(test_data[start_index+j]);
@ -973,7 +973,7 @@ TEST_F(MM_stl_checkpoint, s_multiset ) {
std::multiset<std::pair<int,int>> expected;
// Prepare the STL to be tested
for (int i = 0; i < test_first.size(); i++) {
for (unsigned int i = 0; i < test_first.size(); i++) {
testbed->s_multiset.insert(std::pair<int,int>(test_first[i], test_second[i]));
testbed->s_multiset.insert(std::pair<int,int>(test_first[i], test_second[i]));
expected.insert(std::pair<int,int>(test_first[i], test_second[i]));
@ -1046,7 +1046,7 @@ TEST_F(MM_stl_checkpoint, i_array ) {
std::vector<char> test_data = get_test_data<char>(10);
// Prepare the STL to be tested
for (int i = 0; i < test_data.size(); i++) {
for (unsigned int i = 0; i < test_data.size(); i++) {
testbed->i_array[i] = test_data[i];
}
@ -1069,7 +1069,7 @@ TEST_F(MM_stl_checkpoint, pair_array ) {
std::vector<int> test_data = get_test_data<int>(20);
// Prepare the STL to be tested
for (int i = 0; i < test_data.size(); i+=2) {
for (unsigned int i = 0; i < test_data.size(); i+=2) {
testbed->pair_array[i/2] = std::pair<int,int>(test_data[i],test_data[i+1]);
}
@ -1080,7 +1080,7 @@ TEST_F(MM_stl_checkpoint, pair_array ) {
(vec_attr->checkpoint_stl)((void *) &testbed->pair_array, "my_alloc", vec_attr->name) ;
// ASSERT
for (int i = 0; i < test_data.size(); i+=2) {
for (unsigned int i = 0; i < test_data.size(); i+=2) {
std::string var_name = "pair_array_" + std::to_string(i/2);
validate_temp_pair(memmgr, std::string("my_alloc"), var_name, std::pair<int,int>(test_data[i],test_data[i+1]));
}
@ -1097,7 +1097,7 @@ TEST_F(MM_stl_checkpoint, string_array ) {
std::vector<std::string> test_data = get_test_data<std::string>(10);
// Prepare the STL to be tested
for (int i = 0; i < test_data.size(); i++) {
for (unsigned int i = 0; i < test_data.size(); i++) {
testbed->string_array[i] = test_data[i];
}
@ -1276,7 +1276,7 @@ TEST_F(MM_stl_checkpoint, recursive_nightmare ) {
}
// Make the map
for (int m = 0; m < keys.size(); m++) {
for (unsigned int m = 0; m < keys.size(); m++) {
testbed->recursive_nightmare[i].insert(std::pair<std::pair<int, int>,std::vector<std::stack<std::string>>>(keys[m], vals[m]));
recursive_nightmare_copy[i].insert(std::pair<std::pair<int, int>,std::vector<std::stack<std::string>>>(keys[m], vals[m]));
}
@ -1302,7 +1302,7 @@ TEST_F(MM_stl_checkpoint, recursive_nightmare ) {
std::string key_var_name = "recursive_nightmare_" + std::to_string(i) + "_keys_" + std::to_string(j);
validate_temp_pair(memmgr, std::string("my_alloc"), key_var_name, key);
for (int k = 0; k < val.size(); k++) {
for (unsigned int k = 0; k < val.size(); k++) {
std::string val_var_name = "recursive_nightmare_" + std::to_string(i) + "_data_" + std::to_string(j) + "_" + std::to_string(k);
std::vector<std::string> val_expected;
while (!val[k].empty()) {

View File

@ -46,7 +46,7 @@ TEST_F(MM_stl_restore, i_vec ) {
std::vector<int> test_data = get_test_data<int>(20);
// Register the expected temporary variables with the memory manager
int * temp_data = (int *) memmgr->declare_var("int my_alloc_i_vec[20]");
for (int i = 0; i < 20; i++) {
for (unsigned int i = 0; i < 20; i++) {
temp_data[i] = test_data[i];
}
@ -75,7 +75,7 @@ TEST_F(MM_stl_restore, i_s_vec ) {
std::string my_alloc_i_s_vec[6];
int start_index = 0;
memmgr->declare_extern_var(&my_alloc_i_s_vec, "std::string my_alloc_i_s_vec[6]");
for (int i = 0; i < lengths.size(); i++) {
for (unsigned int i = 0; i < lengths.size(); i++) {
// std::string var_name =
my_alloc_i_s_vec[i] = "my_alloc_i_s_vec_" + std::to_string(i);
@ -95,7 +95,7 @@ TEST_F(MM_stl_restore, i_s_vec ) {
// Make sure the STL has been populated
ASSERT_EQ(testbed->i_s_vec.size(), lengths.size());
start_index = 0;
for (int i = 0; i < lengths.size(); i++) {
for (unsigned int i = 0; i < lengths.size(); i++) {
ASSERT_EQ(testbed->i_s_vec[i].size(), lengths[i]);
EXPECT_EQ(testbed->i_s_vec[i], std::vector<int>(test_data.begin()+start_index, test_data.begin()+start_index+lengths[i]));
start_index += lengths[i];
@ -103,7 +103,7 @@ TEST_F(MM_stl_restore, i_s_vec ) {
// Check that all the temporary variables have been deleted
EXPECT_EQ(memmgr->var_exists("my_alloc_i_s_vec"), 0);
for (int i = 0; i < test_data.size()/2; i++) {
for (unsigned int i = 0; i < test_data.size()/2; i++) {
EXPECT_EQ(memmgr->var_exists("my_alloc_i_s_vec_" + std::to_string(i)), 0);
EXPECT_EQ(memmgr->var_exists("my_alloc_i_s_vec_" + std::to_string(i)), 0);
}
@ -119,7 +119,7 @@ TEST_F(MM_stl_restore, s_vec ) {
// Register the expected temporary variables with the memory manager
std::string my_alloc_s_vec[20];
memmgr->declare_extern_var(&my_alloc_s_vec, "std::string my_alloc_s_vec[20]");
for (int i = 0; i < test_data.size()/2; i++) {
for (unsigned int i = 0; i < test_data.size()/2; i++) {
my_alloc_s_vec[i] = "my_alloc_s_vec_" + std::to_string(i);
std::string first_var_name = "int my_alloc_s_vec_" + std::to_string(i) + "_first";
@ -138,14 +138,14 @@ TEST_F(MM_stl_restore, s_vec ) {
// ASSERT
// Make sure the STL has been populated
ASSERT_EQ(testbed->s_vec.size(), test_data.size()/2);
for (int i = 0; i < test_data.size()/2; i++) {
for (unsigned int i = 0; i < test_data.size()/2; i++) {
EXPECT_EQ(testbed->s_vec[i].first, test_data[i*2]);
EXPECT_EQ(testbed->s_vec[i].second, test_data[i*2+1]);
}
// Check that all the temporary variables have been deleted
EXPECT_EQ(memmgr->var_exists("my_alloc_s_vec"), 0);
for (int i = 0; i < test_data.size()/2; i++) {
for (unsigned int i = 0; i < test_data.size()/2; i++) {
EXPECT_EQ(memmgr->var_exists("my_alloc_s_vec_" + std::to_string(i) + "_first"), 0);
EXPECT_EQ(memmgr->var_exists("my_alloc_s_vec_" + std::to_string(i) + "_second"), 0);
}
@ -160,7 +160,7 @@ TEST_F(MM_stl_restore, string_vec ) {
// Register the expected temporary variables with the memory manager
std::string * temp_data = (std::string *) memmgr->declare_var("std::string my_alloc_string_vec[20]");
for (int i = 0; i < 20; i++) {
for (unsigned int i = 0; i < 20; i++) {
temp_data[i] = std::string(test_data[i]);
}
@ -222,7 +222,7 @@ TEST_F(MM_stl_restore, i_s_pair ) {
*first_data = test_first;
*second_link = std::string("inner");
for (int i = 0; i < test_second.size(); i++) {
for (unsigned int i = 0; i < test_second.size(); i++) {
second_data[i] = test_second[i];
}
@ -235,7 +235,7 @@ TEST_F(MM_stl_restore, i_s_pair ) {
// Make sure the STL has been populated
EXPECT_EQ(testbed->i_s_pair.first, test_first);
EXPECT_EQ(testbed->i_s_pair.second.size(), test_second.size());
for (int i = 0; i < test_second.size(); i++) {
for (unsigned int i = 0; i < test_second.size(); i++) {
EXPECT_EQ(testbed->i_s_pair.second.front(), test_second[i]);
testbed->i_s_pair.second.pop();
}
@ -259,7 +259,7 @@ TEST_F(MM_stl_restore, s_i_pair ) {
*first_link = "inner";
double * second_data = (double *) memmgr->declare_var("double my_alloc_s_i_pair_second");
for (int i = 0; i < test_first.size(); i++) {
for (unsigned int i = 0; i < test_first.size(); i++) {
first_data[i] = test_first[i];
}
*second_data = test_second;
@ -274,7 +274,7 @@ TEST_F(MM_stl_restore, s_i_pair ) {
// Make sure the STL has been populated
EXPECT_EQ(testbed->s_i_pair.second, test_second);
ASSERT_EQ(testbed->s_i_pair.first.size(), test_first.size());
for (int i = 0; i < test_first.size(); i++) {
for (unsigned int i = 0; i < test_first.size(); i++) {
EXPECT_EQ(testbed->s_i_pair.first.front(), test_first[i]);
testbed->s_i_pair.first.pop();
}
@ -303,10 +303,10 @@ TEST_F(MM_stl_restore, s_s_pair ) {
for (int i = 0; i < test_first.size(); i++) {
for (unsigned int i = 0; i < test_first.size(); i++) {
first_data[i] = test_first[i];
}
for (int i = 0; i < test_second.size(); i++) {
for (unsigned int i = 0; i < test_second.size(); i++) {
second_data[i] = test_second[i];
}
@ -319,7 +319,7 @@ TEST_F(MM_stl_restore, s_s_pair ) {
// Make sure the STL has been populated
EXPECT_EQ(testbed->s_s_pair.first.size(), test_first.size());
EXPECT_EQ(testbed->s_s_pair.second.size(), test_second.size());
for (int i = 0; i < test_first.size(); i++) {
for (unsigned int i = 0; i < test_first.size(); i++) {
EXPECT_EQ(testbed->s_s_pair.first[i], test_first[i]);
EXPECT_EQ(testbed->s_s_pair.second.top(), test_second[i]);
testbed->s_s_pair.second.pop();
@ -380,7 +380,7 @@ TEST_F(MM_stl_restore, i_i_map ) {
int * key_data = (int *) memmgr->declare_var("int my_alloc_i_i_map_keys[20]");
double * val_data = (double *) memmgr->declare_var("double my_alloc_i_i_map_data[20]");
for (int i = 0; i < test_keys.size(); i++) {
for (unsigned int i = 0; i < test_keys.size(); i++) {
key_data[i] = test_keys[i];
val_data[i] = test_data[i];
@ -413,7 +413,7 @@ TEST_F(MM_stl_restore, i_s_map ) {
int * key_data = (int *) memmgr->declare_var("int my_alloc_i_s_map_keys[10]");
std::string * val_data = (std::string *) memmgr->declare_var("std::string my_alloc_i_s_map_data[10]");
for (int i = 0; i < test_keys.size(); i++) {
for (unsigned int i = 0; i < test_keys.size(); i++) {
key_data[i] = test_keys[i];
val_data[i] = std::string("my_alloc_i_s_map_data_" + std::to_string(i));
@ -421,7 +421,7 @@ TEST_F(MM_stl_restore, i_s_map ) {
std::string * val_temp = (std::string *) memmgr->declare_var(var_name.c_str());
std::vector<std::string> test_strings_easy = {"a", "b", "c", "d", "e", "f"};
for (int j = 0; j < 6; j++) {
for (unsigned int j = 0; j < 6; j++) {
// val_temp[j] = std::string(test_data[(i*6) + j]);
val_temp[j] = std::string(test_strings_easy[j]);
@ -444,7 +444,7 @@ TEST_F(MM_stl_restore, i_s_map ) {
// Check that all the temporary variables have been deleted
EXPECT_EQ(memmgr->var_exists("my_alloc_i_s_map_keys"), 0);
EXPECT_EQ(memmgr->var_exists("my_alloc_i_s_map_data"), 0);
for (int i = 0; i < testbed->i_s_map.size(); i++) {
for (unsigned int i = 0; i < testbed->i_s_map.size(); i++) {
std::string var_name_test = "my_alloc_i_s_map_data_" + std::to_string(i);
EXPECT_EQ(memmgr->var_exists(var_name_test.c_str()), 0);
}
@ -461,14 +461,14 @@ TEST_F(MM_stl_restore, s_i_map ) {
std::string * key_data = (std::string *) memmgr->declare_var("std::string my_alloc_s_i_map_keys[10]");
std::string * val_data = (std::string *) memmgr->declare_var("std::string my_alloc_s_i_map_data[10]");
for (int i = 0; i < test_data.size(); i++) {
for (unsigned int i = 0; i < test_data.size(); i++) {
key_data[i] = std::string("my_alloc_s_i_map_keys_" + std::to_string(i));
std::string var_name = "int my_alloc_s_i_map_keys_" + std::to_string(i) + "[" + std::to_string(3) + "]";
int * val_temp = (int *) memmgr->declare_var(var_name.c_str());
std::set<int> temp_set;
for (int j = 0; j < 3; j++) {
for (unsigned int j = 0; j < 3; j++) {
val_temp[j] = test_keys[(i*3) + j];
// Create a map of expected data along side so that we don't have to deal with ordering stuff
@ -493,7 +493,7 @@ TEST_F(MM_stl_restore, s_i_map ) {
// Check that all the temporary variables have been deleted
EXPECT_EQ(memmgr->var_exists("my_alloc_s_i_map_keys"), 0);
EXPECT_EQ(memmgr->var_exists("my_alloc_s_i_map_data"), 0);
for (int i = 0; i < testbed->i_s_map.size(); i++) {
for (unsigned int i = 0; i < testbed->i_s_map.size(); i++) {
std::string var_name_test = "my_alloc_s_i_map_keys_" + std::to_string(i);
EXPECT_EQ(memmgr->var_exists(var_name_test.c_str()), 0);
}
@ -534,7 +534,7 @@ TEST_F(MM_stl_restore, s_s_map ) {
std::string data_name = "int my_alloc_s_s_map_data_" + std::to_string(i) + "[" + std::to_string(4) + "]";
int * data_values = (int *) memmgr->declare_var(data_name.c_str());
for (int j = 0; j < 4; j++) {
for (unsigned int j = 0; j < 4; j++) {
data_values[j] = test_data[(i*4) + j];
// Create a map of expected data along side so that we don't have to deal with ordering stuff
@ -578,7 +578,7 @@ TEST_F(MM_stl_restore, i_queue ) {
std::queue<int> expected_data;
// Register the expected temporary variables with the memory manager
int * temp_data = (int *) memmgr->declare_var("int my_alloc_i_queue[20]");
for (int i = 0; i < 20; i++) {
for (unsigned int i = 0; i < 20; i++) {
temp_data[i] = test_data[i];
expected_data.push(test_data[i]);
}
@ -608,7 +608,7 @@ TEST_F(MM_stl_restore, s_queue ) {
std::string * data_links = (std::string *) memmgr->declare_var("std::string my_alloc_s_queue[20]");
for (int i = 0; i < test_first.size(); i++) {
for (unsigned int i = 0; i < test_first.size(); i++) {
data_links[i] = "my_alloc_s_queue_" + std::to_string(i);
std::string first_var_name = "int my_alloc_s_queue_" + std::to_string(i) + "_first";
@ -632,7 +632,7 @@ TEST_F(MM_stl_restore, s_queue ) {
// Check that all the temporary variables have been deleted
EXPECT_EQ(memmgr->var_exists("my_alloc_s_queue"), 0);
for (int i = 0; i < test_first.size(); i++) {
for (unsigned int i = 0; i < test_first.size(); i++) {
EXPECT_EQ(memmgr->var_exists("my_alloc_s_queue_" + std::to_string(i) + "_first"), 0);
EXPECT_EQ(memmgr->var_exists("my_alloc_s_queue_" + std::to_string(i) + "_second"), 0);
}
@ -653,13 +653,13 @@ TEST_F(MM_stl_restore, nested_list_queue ) {
int start_index = 0;
std::string * nested_list_links = (std::string *) memmgr->declare_var( "std::string my_alloc_nested_list_queue[6]");
for (int i = 0; i < lengths.size(); i++) {
for (unsigned int i = 0; i < lengths.size(); i++) {
nested_list_links[i] = "my_alloc_nested_list_queue_" + std::to_string(i);
std::string temp_var_name = "float my_alloc_nested_list_queue_" + std::to_string(i) + "[" + std::to_string(lengths[i]) + "]";
std::list<float> temp_expected;
float * temp_arr = (float *)memmgr->declare_var(temp_var_name.c_str());
for (int j = 0; j < lengths[i]; j++) {
for ( int j = 0; j < lengths[i]; j++) {
temp_arr[j] = test_data[start_index + j];
temp_expected.push_back(test_data[start_index + j]);
}
@ -678,7 +678,7 @@ TEST_F(MM_stl_restore, nested_list_queue ) {
// Check that all the temporary variables have been deleted
EXPECT_EQ(memmgr->var_exists("my_alloc_nested_list_queue"), 0);
for (int i = 0; i < test_data.size()/2; i++) {
for (unsigned int i = 0; i < test_data.size()/2; i++) {
EXPECT_EQ(memmgr->var_exists("my_alloc_nested_list_queue_" + std::to_string(i)), 0);
EXPECT_EQ(memmgr->var_exists("my_alloc_nested_list_queue_" + std::to_string(i)), 0);
}
@ -695,7 +695,7 @@ TEST_F(MM_stl_restore, i_stack ) {
std::stack<long long> expected_data;
// Register the expected temporary variables with the memory manager
long long * temp_data = (long long *) memmgr->declare_var("long long my_alloc_i_stack[20]");
for (int i = 0; i < test_data.size(); i++) {
for (unsigned int i = 0; i < test_data.size(); i++) {
temp_data[i] = test_data[i];
// push backwards bc stack
@ -726,7 +726,7 @@ TEST_F(MM_stl_restore, s_stack ) {
std::string * data_links = (std::string *) memmgr->declare_var("std::string my_alloc_s_stack[20]");
for (int i = 0; i < test_first.size(); i++) {
for (unsigned int i = 0; i < test_first.size(); i++) {
data_links[i] = "my_alloc_s_stack_" + std::to_string(i);
std::string first_var_name = "short my_alloc_s_stack_" + std::to_string(i) + "_first";
@ -751,7 +751,7 @@ TEST_F(MM_stl_restore, s_stack ) {
// Check that all the temporary variables have been deleted
EXPECT_EQ(memmgr->var_exists("my_alloc_s_stack"), 0);
for (int i = 0; i < test_first.size(); i++) {
for (unsigned int i = 0; i < test_first.size(); i++) {
EXPECT_EQ(memmgr->var_exists("my_alloc_s_stack_" + std::to_string(i) + "_first"), 0);
EXPECT_EQ(memmgr->var_exists("my_alloc_s_stack_" + std::to_string(i) + "_second"), 0);
}
@ -774,7 +774,7 @@ TEST_F(MM_stl_restore, nested_list_stack ) {
// Register the expected temporary variables with the memory manager
int start_index = 0;
std::string * nested_list_links = (std::string *) memmgr->declare_var( "std::string my_alloc_nested_list_stack[6]");
for (int i = 0; i < lengths.size(); i++) {
for (unsigned int i = 0; i < lengths.size(); i++) {
nested_list_links[i] = "my_alloc_nested_list_stack_" + std::to_string(i);
std::string temp_var_name = "float my_alloc_nested_list_stack_" + std::to_string(i) + "[" + std::to_string(lengths[i]) + "]";
@ -805,7 +805,7 @@ TEST_F(MM_stl_restore, nested_list_stack ) {
// Check that all the temporary variables have been deleted
EXPECT_EQ(memmgr->var_exists("my_alloc_nested_list_stack"), 0);
for (int i = 0; i < test_data.size()/2; i++) {
for (unsigned int i = 0; i < test_data.size()/2; i++) {
EXPECT_EQ(memmgr->var_exists("my_alloc_nested_list_stack_" + std::to_string(i)), 0);
}
}
@ -858,7 +858,7 @@ TEST_F(MM_stl_restore, s_set ) {
std::string * data_links = (std::string *) memmgr->declare_var("std::string my_alloc_s_set[20]");
for (int i = 0; i < test_first.size(); i++) {
for (unsigned int i = 0; i < test_first.size(); i++) {
data_links[i] = "my_alloc_s_set_" + std::to_string(i);
std::string first_var_name = "int my_alloc_s_set_" + std::to_string(i) + "_first";
@ -882,7 +882,7 @@ TEST_F(MM_stl_restore, s_set ) {
// Check that all the temporary variables have been deleted
EXPECT_EQ(memmgr->var_exists("my_alloc_s_set"), 0);
for (int i = 0; i < test_first.size(); i++) {
for (unsigned int i = 0; i < test_first.size(); i++) {
EXPECT_EQ(memmgr->var_exists("my_alloc_s_set_" + std::to_string(i) + "_first"), 0);
EXPECT_EQ(memmgr->var_exists("my_alloc_s_set_" + std::to_string(i) + "_second"), 0);
}
@ -904,7 +904,7 @@ TEST_F(MM_stl_restore, vector_set ) {
// Register the expected temporary variables with the memory manager
int start_index = 0;
std::string * nested_list_links = (std::string *) memmgr->declare_var( "std::string my_alloc_vector_set[6]");
for (int i = 0; i < lengths.size(); i++) {
for (unsigned int i = 0; i < lengths.size(); i++) {
nested_list_links[i] = "my_alloc_vector_set_" + std::to_string(i);
std::string temp_var_name = "int my_alloc_vector_set_" + std::to_string(i) + "[" + std::to_string(lengths[i]) + "]";
@ -929,7 +929,7 @@ TEST_F(MM_stl_restore, vector_set ) {
// Check that all the temporary variables have been deleted
EXPECT_EQ(memmgr->var_exists("my_alloc_vector_set"), 0);
for (int i = 0; i < test_data.size()/2; i++) {
for (unsigned int i = 0; i < test_data.size()/2; i++) {
EXPECT_EQ(memmgr->var_exists("my_alloc_vector_set_" + std::to_string(i)), 0);
}
}
@ -946,7 +946,7 @@ TEST_F(MM_stl_restore, nested_map_set ) {
std::set<std::map<short,double>> expected;
std::string * nested_map_links = (std::string *) memmgr->declare_var( "std::string my_alloc_nested_map_set[6]");
for (int i = 0; i < 6; i++) {
for (unsigned int i = 0; i < 6; i++) {
nested_map_links[i] = "my_alloc_nested_map_set_" + std::to_string(i);
std::string keys_var_name = "short my_alloc_nested_map_set_" + std::to_string(i) + "_keys[10]";
@ -956,7 +956,7 @@ TEST_F(MM_stl_restore, nested_map_set ) {
double * map_vals_temp = (double *) memmgr->declare_var( vals_var_name.c_str() );
std::map<short,double> temp_map;
for (int j = 0; j < 10; j++) {
for (unsigned int j = 0; j < 10; j++) {
map_keys_temp[j] = test_keys[(i*10) + j];
map_vals_temp[j] = test_vals[(i*10) + j];
@ -975,7 +975,7 @@ TEST_F(MM_stl_restore, nested_map_set ) {
// Check that all the temporary variables have been deleted
EXPECT_EQ(memmgr->var_exists("my_alloc_nested_map_set"), 0);
for (int i = 0; i < expected.size(); i++) {
for (unsigned int i = 0; i < expected.size(); i++) {
EXPECT_EQ(memmgr->var_exists("my_alloc_nested_map_set_" + std::to_string(i) + "_data"), 0);
EXPECT_EQ(memmgr->var_exists("my_alloc_nested_map_set_" + std::to_string(i) + "_vals"), 0);
}
@ -1032,9 +1032,9 @@ TEST_F(MM_stl_restore, s_multiset ) {
std::string * data_links = (std::string *) memmgr->declare_var("std::string my_alloc_s_multiset[40]");
for (int i = 0; i < test_first.size(); i++) {
for (unsigned int i = 0; i < test_first.size(); i++) {
// just insert the same thing twice
for (int j = 0; j < 2; j++) {
for (unsigned int j = 0; j < 2; j++) {
data_links[i*2+j] = "my_alloc_s_multiset_" + std::to_string(i*2+j);
std::string first_var_name = "int my_alloc_s_multiset_" + std::to_string(i*2+j) + "_first";
@ -1059,7 +1059,7 @@ TEST_F(MM_stl_restore, s_multiset ) {
// Check that all the temporary variables have been deleted
EXPECT_EQ(memmgr->var_exists("my_alloc_s_multiset"), 0);
for (int i = 0; i < expected.size(); i++) {
for (unsigned int i = 0; i < expected.size(); i++) {
EXPECT_EQ(memmgr->var_exists("my_alloc_s_multiset_" + std::to_string(i) + "_first"), 0);
EXPECT_EQ(memmgr->var_exists("my_alloc_s_multiset_" + std::to_string(i) + "_second"), 0);
}
@ -1081,8 +1081,8 @@ TEST_F(MM_stl_restore, vector_multiset ) {
// Register the expected temporary variables with the memory manager
int start_index = 0;
std::string * nested_list_links = (std::string *) memmgr->declare_var( "std::string my_alloc_vector_multiset[12]");
for (int i = 0; i < lengths.size(); i++) {
for (int j = 0; j < 2; j++) {
for (unsigned int i = 0; i < lengths.size(); i++) {
for (unsigned int j = 0; j < 2; j++) {
nested_list_links[i*2+j] = "my_alloc_vector_multiset_" + std::to_string(i*2+j);
std::string temp_var_name = "int my_alloc_vector_multiset_" + std::to_string(i*2+j) + "[" + std::to_string(lengths[i]) + "]";
@ -1108,7 +1108,7 @@ TEST_F(MM_stl_restore, vector_multiset ) {
// Check that all the temporary variables have been deleted
EXPECT_EQ(memmgr->var_exists("my_alloc_vector_multiset"), 0);
for (int i = 0; i < expected.size(); i++) {
for (unsigned int i = 0; i < expected.size(); i++) {
EXPECT_EQ(memmgr->var_exists("my_alloc_vector_multiset_" + std::to_string(i)), 0);
}
}
@ -1125,8 +1125,8 @@ TEST_F(MM_stl_restore, nested_map_multiset ) {
std::multiset<std::map<short,double>> expected;
std::string * nested_map_links = (std::string *) memmgr->declare_var( "std::string my_alloc_nested_map_multiset[12]");
for (int i = 0; i < 6; i++) {
for (int k = 0; k < 2; k++) {
for (unsigned int i = 0; i < 6; i++) {
for (unsigned int k = 0; k < 2; k++) {
nested_map_links[i] = "my_alloc_nested_map_multiset_" + std::to_string(i*2+k);
std::string keys_var_name = "short my_alloc_nested_map_multiset_" + std::to_string(i*2+k) + "_keys[10]";
@ -1136,7 +1136,7 @@ TEST_F(MM_stl_restore, nested_map_multiset ) {
double * map_vals_temp = (double *) memmgr->declare_var( vals_var_name.c_str() );
std::map<short,double> temp_map;
for (int j = 0; j < 10; j++) {
for (unsigned int j = 0; j < 10; j++) {
map_keys_temp[j] = test_keys[(i*10) + j];
map_vals_temp[j] = test_vals[(i*10) + j];
@ -1155,7 +1155,7 @@ TEST_F(MM_stl_restore, nested_map_multiset ) {
// Check that all the temporary variables have been deleted
EXPECT_EQ(memmgr->var_exists("my_alloc_nested_map_multiset"), 0);
for (int i = 0; i < expected.size(); i++) {
for (unsigned int i = 0; i < expected.size(); i++) {
EXPECT_EQ(memmgr->var_exists("my_alloc_nested_map_multiset_" + std::to_string(i) + "_data"), 0);
EXPECT_EQ(memmgr->var_exists("my_alloc_nested_map_multiset_" + std::to_string(i) + "_vals"), 0);
}
@ -1172,7 +1172,7 @@ TEST_F(MM_stl_restore, i_array ) {
// Register the expected temporary variables with the memory manager
char * temp_data = (char *) memmgr->declare_var("char my_alloc_i_array[10]");
for (int i = 0; i < test_data.size(); i++) {
for (unsigned int i = 0; i < test_data.size(); i++) {
temp_data[i] = test_data[i];
expected[i] = test_data[i];
}
@ -1201,7 +1201,7 @@ TEST_F(MM_stl_restore, pair_array ) {
std::string * data_links = (std::string *) memmgr->declare_var("std::string my_alloc_pair_array[10]");
for (int i = 0; i < test_first.size(); i++) {
for (unsigned int i = 0; i < test_first.size(); i++) {
data_links[i] = "my_alloc_pair_array_" + std::to_string(i);
std::string first_var_name = "int my_alloc_pair_array_" + std::to_string(i) + "_first";
@ -1225,7 +1225,7 @@ TEST_F(MM_stl_restore, pair_array ) {
// Check that all the temporary variables have been deleted
EXPECT_EQ(memmgr->var_exists("my_alloc_pair_array"), 0);
for (int i = 0; i < test_first.size(); i++) {
for (unsigned int i = 0; i < test_first.size(); i++) {
EXPECT_EQ(memmgr->var_exists("my_alloc_pair_array_" + std::to_string(i) + "_first"), 0);
EXPECT_EQ(memmgr->var_exists("my_alloc_pair_array_" + std::to_string(i) + "_second"), 0);
}
@ -1242,7 +1242,7 @@ TEST_F(MM_stl_restore, string_array ) {
// Register the expected temporary variables with the memory manager
std::string * temp_data = (std::string *) memmgr->declare_var("std::string my_alloc_string_array[10]");
for (int i = 0; i < test_data.size(); i++) {
for (unsigned int i = 0; i < test_data.size(); i++) {
temp_data[i] = std::string(test_data[i]);
expected[i] = std::string(test_data[i]);
}
@ -1272,7 +1272,7 @@ TEST_F(MM_stl_restore, vec_array ) {
std::string my_alloc_vec_array[10];
int start_index = 0;
memmgr->declare_extern_var(&my_alloc_vec_array, "std::string my_alloc_vec_array[10]");
for (int i = 0; i < lengths.size(); i++) {
for (unsigned int i = 0; i < lengths.size(); i++) {
// std::string var_name =
my_alloc_vec_array[i] = "my_alloc_vec_array_" + std::to_string(i);
@ -1292,7 +1292,7 @@ TEST_F(MM_stl_restore, vec_array ) {
// Make sure the STL has been populated
ASSERT_EQ(testbed->vec_array.size(), lengths.size());
start_index = 0;
for (int i = 0; i < lengths.size(); i++) {
for (unsigned int i = 0; i < lengths.size(); i++) {
ASSERT_EQ(testbed->vec_array[i].size(), lengths[i]);
EXPECT_EQ(testbed->vec_array[i], std::vector<int>(test_data.begin()+start_index, test_data.begin()+start_index+lengths[i]));
start_index += lengths[i];
@ -1300,7 +1300,7 @@ TEST_F(MM_stl_restore, vec_array ) {
// Check that all the temporary variables have been deleted
EXPECT_EQ(memmgr->var_exists("my_alloc_vec_array"), 0);
for (int i = 0; i < test_data.size()/2; i++) {
for (unsigned int i = 0; i < test_data.size()/2; i++) {
EXPECT_EQ(memmgr->var_exists("my_alloc_vec_array_" + std::to_string(i)), 0);
EXPECT_EQ(memmgr->var_exists("my_alloc_vec_array_" + std::to_string(i)), 0);
}

View File

@ -0,0 +1,164 @@
#include <gtest/gtest.h>
#include "trick/parameter_types.h"
#include <iostream>
/* ================================================================================
* Test Cases
*/
TEST( MM_tricktypecharstring, TRICK_VOID_test) {
const char* name = "some_name";
const char* result = trickTypeCharString(TRICK_VOID, name);
EXPECT_STREQ(result, "void");
}
TEST( MM_tricktypecharstring, TRICK_CHARACTER_test) {
const char* name = "some_name";
const char* result = trickTypeCharString(TRICK_CHARACTER, name);
EXPECT_STREQ(result, "char");
}
TEST( MM_tricktypecharstring, TRICK_UNSIGNED_CHARACTER_test) {
const char* name = "some_name";
const char* result = trickTypeCharString(TRICK_UNSIGNED_CHARACTER, name);
EXPECT_STREQ(result, "unsigned char");
}
TEST( MM_tricktypecharstring, TRICK_STRING_test) {
const char* name = "some_name";
const char* result = trickTypeCharString(TRICK_STRING, name);
EXPECT_STREQ(result, "std::string");
}
TEST( MM_tricktypecharstring, TRICK_SHORT_test) {
const char* name = "some_name";
const char* result = trickTypeCharString(TRICK_SHORT, name);
EXPECT_STREQ(result, "short");
}
TEST( MM_tricktypecharstring, TRICK_UNSIGNED_SHORT_test) {
const char* name = "some_name";
const char* result = trickTypeCharString(TRICK_UNSIGNED_SHORT, name);
EXPECT_STREQ(result, "unsigned short");
}
TEST( MM_tricktypecharstring, TRICK_INTEGER_test) {
const char* name = "some_name";
const char* result = trickTypeCharString(TRICK_INTEGER, name);
EXPECT_STREQ(result, "int");
}
TEST( MM_tricktypecharstring, TRICK_UNSIGNED_INTEGER_test) {
const char* name = "some_name";
const char* result = trickTypeCharString(TRICK_UNSIGNED_INTEGER, name);
EXPECT_STREQ(result, "unsigned int");
}
TEST( MM_tricktypecharstring, TRICK_LONG_test) {
const char* name = "some_name";
const char* result = trickTypeCharString(TRICK_LONG, name);
EXPECT_STREQ(result, "long");
}
TEST( MM_tricktypecharstring, TRICK_UNSIGNED_LONG_test) {
const char* name = "some_name";
const char* result = trickTypeCharString(TRICK_UNSIGNED_LONG, name);
EXPECT_STREQ(result, "unsigned long");
}
TEST( MM_tricktypecharstring, TRICK_FLOAT_test) {
const char* name = "some_name";
const char* result = trickTypeCharString(TRICK_FLOAT, name);
EXPECT_STREQ(result, "float");
}
TEST( MM_tricktypecharstring, TRICK_DOUBLE_test) {
const char* name = "some_name";
const char* result = trickTypeCharString(TRICK_DOUBLE, name);
EXPECT_STREQ(result, "double");
}
TEST( MM_tricktypecharstring, TRICK_BITFIELD_test) {
const char* name = "some_name";
const char* result = trickTypeCharString(TRICK_BITFIELD, name);
EXPECT_STREQ(result, "TRICK_BITFIELD");
}
TEST( MM_tricktypecharstring, TRICK_UNSIGNED_BITFIELD_test) {
const char* name = "some_name";
const char* result = trickTypeCharString(TRICK_UNSIGNED_BITFIELD, name);
EXPECT_STREQ(result, "TRICK_UNSIGNED_BITFIELD");
}
TEST( MM_tricktypecharstring, TRICK_LONG_LONG_test) {
const char* name = "some_name";
const char* result = trickTypeCharString(TRICK_LONG_LONG, name);
EXPECT_STREQ(result, "long long");
}
TEST( MM_tricktypecharstring, TRICK_UNSIGNED_LONG_LONG_test) {
const char* name = "some_name";
const char* result = trickTypeCharString(TRICK_UNSIGNED_LONG_LONG, name);
EXPECT_STREQ(result, "unsigned long long");
}
TEST( MM_tricktypecharstring, TRICK_FILE_PTR_test) {
const char* name = "some_name";
const char* result = trickTypeCharString(TRICK_FILE_PTR, name);
EXPECT_STREQ(result, "FILE*");
}
TEST( MM_tricktypecharstring, TRICK_BOOLEAN_test) {
const char* name = "some_name";
const char* result = trickTypeCharString(TRICK_BOOLEAN, name);
EXPECT_STREQ(result, "bool");
}
TEST( MM_tricktypecharstring, TRICK_WCHAR_test) {
const char* name = "some_name";
const char* result = trickTypeCharString(TRICK_WCHAR, name);
EXPECT_STREQ(result, "wchar_t");
}
TEST( MM_tricktypecharstring, TRICK_WSTRING_test) {
const char* name = "some_name";
const char* result = trickTypeCharString(TRICK_WSTRING, name);
EXPECT_STREQ(result, "wchar_t*");
}
TEST( MM_tricktypecharstring, TRICK_VOID_PTR_test) {
const char* name = "some_name";
const char* result = trickTypeCharString(TRICK_VOID_PTR, name);
EXPECT_STREQ(result, "void*");
}
TEST( MM_tricktypecharstring, TRICK_ENUMERATED_test) {
const char* name = "some_name";
const char* result = trickTypeCharString(TRICK_ENUMERATED, name);
EXPECT_STREQ(result, name);
}
TEST( MM_tricktypecharstring, TRICK_STRUCTURED_test) {
const char* name = "some_name";
const char* result = trickTypeCharString(TRICK_STRUCTURED, name);
EXPECT_STREQ(result, name);
}
TEST( MM_tricktypecharstring, TRICK_OPAQUE_TYPE_test) {
const char* name = "some_name";
const char* result = trickTypeCharString(TRICK_OPAQUE_TYPE, name);
EXPECT_STREQ(result, name);
}
TEST( MM_tricktypecharstring, TRICK_STL_test) {
const char* name = "some_name";
const char* result = trickTypeCharString(TRICK_STL, name);
EXPECT_STREQ(result, name);
}
TEST( MM_tricktypecharstring, DEFAULT_test) {
const char* name = "some_name";
const char* result = trickTypeCharString(TRICK_NUMBER_OF_TYPES, name);
EXPECT_STREQ(result, "UNKNOWN_TYPE");
}

View File

@ -1,7 +1,6 @@
#SYNOPSIS:
#
# make [all] - makes everything.
# SYNOPSIS:
# make [all] - makes and runs tests.
# make tests - makes tests.
# make TARGET - makes the given target.
# make clean - removes all files generated by make.
@ -18,19 +17,9 @@ TRICK_CPPFLAGS += -I$(GTEST_HOME)/include -I$(TRICK_HOME)/include -g -Wall -Wext
TRICK_LIBS = -L${TRICK_LIB_DIR} -ltrick_mm -ltrick_units -ltrick -ltrick_mm -ltrick_units -ltrick
TRICK_EXEC_LINK_LIBS += -L${GTEST_HOME}/lib64 -L${GTEST_HOME}/lib -lgtest -lgtest_main -lpthread
# This is supposed to be a development hack so that I don't have to clean rebuild Trick every time I change the stl_checkpoint files.
# This should be deleted before it is merged into master.
STL_CHECKPOINT_FILES = checkpoint_pair.hh \
checkpoint_sequence_stl.hh \
checkpoint_map.hh \
checkpoint_queue.hh \
checkpoint_stack.hh
STL_CHECKPOINT_DEPS = $(addprefix $(TRICK_HOME)/include/trick/, $(STL_CHECKPOINT_FILES))
# All tests produced by this Makefile. Remember to add new tests you
# created to the list.
# ==================================================================================
# All tests produced by this Makefile. Add new tests you create to this list.
# ==================================================================================
TESTS = MM_creation_unittest \
MM_declare_var_unittest \
MM_declare_var_2_unittest \
@ -48,206 +37,100 @@ TESTS = MM_creation_unittest \
MM_write_checkpoint_hexfloat \
MM_get_enumerated\
MM_ref_name_from_address \
Bitfield_tests \
MM_stl_checkpoint \
MM_stl_restore
Bitfield_tests \
MM_stl_checkpoint \
MM_stl_restore \
MM_trick_type_char_string
#OTHER_OBJECTS = ../../include/object_${TRICK_HOST_CPU}/io_JobData.o \
# ../../include/object_${TRICK_HOST_CPU}/io_SimObject.o
# List of XML files produced by the tests.
unittest_results = $(patsubst %,%.xml,$(TESTS))
# House-keeping build targets.
# List if Test-specific object files.
unittest_objects = $(patsubst %,%.o,$(TESTS))
# ==================================================================================
# The header files that need to be ICG'ed , and compiled for the unittests above.
# Add the header file that need to be ICG'ed here.
# ==================================================================================
io_headers = MM_user_defined_types.hh \
MM_alloc_deps.hh \
MM_write_checkpoint.hh \
MM_get_enumerated.hh \
MM_ref_name_from_address.hh \
MM_stl_testbed.hh
# List of .cpp files produced by ICG from the io_headers.
io_source = $(patsubst %.hh,io_%.cpp,$(io_headers))
# List of .o files produced by compiling the io_source files.
io_objects = $(patsubst %.cpp,%.o,$(io_source))
# ==================================================================================
# TARGETS
# ==================================================================================
all : test
test: $(TESTS)
./MM_creation_unittest --gtest_output=xml:${TRICK_HOME}/trick_test/MM_creation.xml
./MM_declare_var_unittest --gtest_output=xml:${TRICK_HOME}/trick_test/MM_declare_var.xml
./MM_declare_var_2_unittest --gtest_output=xml:${TRICK_HOME}/trick_test/MM_declare_var_2.xml
./MM_declare_extern_var_unittest --gtest_output=xml:${TRICK_HOME}/trick_test/MM_declare_extern_var.xml
./MM_delete_var_unittest --gtest_output=xml:${TRICK_HOME}/trick_test/MM_delete_var.xml
./MM_ref_attributes_unittest --gtest_output=xml:${TRICK_HOME}/trick_test/MM_ref_attributes.xml
./MM_resize_array_unittest --gtest_output=xml:${TRICK_HOME}/trick_test/MM_resize_array.xml
./MM_strdup_unittest --gtest_output=xml:${TRICK_HOME}/trick_test/MM_strdup.xml
./MM_write_var_unittest --gtest_output=xml:${TRICK_HOME}/trick_test/MM_write_var.xml
./MM_sizeof_type_unittest --gtest_output=xml:${TRICK_HOME}/trick_test/MM_sizeof_type.xml
./MM_read_checkpoint --gtest_output=xml:${TRICK_HOME}/trick_test/MM_read_checkpoint_from_string.xml
./MM_clear_var_unittest --gtest_output=xml:${TRICK_HOME}/trick_test/MM_clear_var.xml
./MM_alloc_deps --gtest_output=xml:${TRICK_HOME}/trick_test/MM_alloc_deps.xml
./MM_write_checkpoint --gtest_output=xml:${TRICK_HOME}/trick_test/MM_write_checkpoint.xml
./MM_write_checkpoint_hexfloat --gtest_output=xml:${TRICK_HOME}/trick_test/MM_write_checkpoint_hexfloat.xml
./MM_get_enumerated --gtest_output=xml:${TRICK_HOME}/trick_test/MM_get_enumerated.xml
./MM_ref_name_from_address --gtest_output=xml:${TRICK_HOME}/trick_test/MM_ref_name_from_address.xml
./Bitfield_tests --gtest_output=xml:${TRICK_HOME}/trick_test/Bitfield_tests.xml
./MM_stl_checkpoint --gtest_output=xml:${TRICK_HOME}/trick_test/MM_stl_checkpoint.xml
./MM_stl_restore --gtest_output=xml:${TRICK_HOME}/trick_test/MM_stl_restore.xml
test: unit_tests $(unittest_results)
code-coverage: test
# Give rid of any old code-coverage HTML we may have.
rm -rf lcov_html
# Gather coverage information about the src code.
lcov --capture \
--directory ../object_${TRICK_HOST_CPU} \
--base-directory ../src \
--output-file src_coverage.info
# Filter out information about directories that we don't care about.
lcov --remove src_coverage.info '/Applications/*' '/usr/include/*' \
--output-file MemoryManager_code_coverage.info
# Generate HTML
genhtml MemoryManager_code_coverage.info \
--output-directory lcov_html
# Clean up
# rm *.info
unit_tests: $(TESTS)
clean :
rm -f $(TESTS)
rm -f *.o
# Remove gcov/gprof files.
rm -f *.gcno
rm -f *.gcda
rm -rf io_src xml
# Builds gtest.a and gtest_main.a.
# ==================================================================================
# Generate JUNIT (XML) Test Results
# ==================================================================================
$(unittest_results): %.xml: %
./$< --gtest_output=xml:${TRICK_HOME}/trick_test/$@
io_MM_user_defined_types.o : MM_user_defined_types.hh
# ==================================================================================
# Build io_src objects needed by tests.
# ==================================================================================
io_source = $(patsubst %.hh,io_%.cpp,$(io_headers))
io_objects = $(patsubst %.cpp,%.o,$(io_source))
$(io_objects): %.o: %.cpp
$(TRICK_CXX) $(TRICK_CPPFLAGS) -c io_src/$<
$(io_source): io_%.cpp: %.hh
${TRICK_HOME}/bin/trick-ICG -sim_services -o ./io_src $(TRICK_CPPFLAGS) $<
$(TRICK_CXX) $(TRICK_CPPFLAGS) -c io_src/io_MM_user_defined_types.cpp
io_MM_alloc_deps.o : MM_alloc_deps.hh
${TRICK_HOME}/bin/trick-ICG -sim_services -o ./io_src $(TRICK_CPPFLAGS) $<
$(TRICK_CXX) $(TRICK_CPPFLAGS) -c io_src/io_MM_alloc_deps.cpp
io_MM_write_checkpoint.o : MM_write_checkpoint.hh
${TRICK_HOME}/bin/trick-ICG -sim_services -o ./io_src $(TRICK_CPPFLAGS) $<
$(TRICK_CXX) $(TRICK_CPPFLAGS) -c io_src/io_MM_write_checkpoint.cpp
io_MM_get_enumerated.o : MM_get_enumerated.hh
${TRICK_HOME}/bin/trick-ICG -sim_services -o ./io_src $(TRICK_CPPFLAGS) $<
$(TRICK_CXX) $(TRICK_CPPFLAGS) -c io_src/io_MM_get_enumerated.cpp
io_MM_ref_name_from_address.o : MM_ref_name_from_address.hh
${TRICK_HOME}/bin/trick-ICG -sim_services -o ./io_src $(TRICK_CPPFLAGS) $<
$(TRICK_CXX) $(TRICK_CPPFLAGS) -c io_src/io_MM_ref_name_from_address.cpp
io_MM_stl_testbed.o : MM_stl_testbed.hh
${TRICK_HOME}/bin/trick-ICG -sim_services -o ./io_src $(TRICK_CPPFLAGS) $<
$(TRICK_CXX) $(TRICK_CPPFLAGS) -c io_src/io_MM_stl_testbed.cpp
MM_creation_unittest.o : MM_creation_unittest.cc
# ==================================================================================
# Build Unit test Objects
# ==================================================================================
$(unittest_objects): %.o: %.cc
$(TRICK_CXX) $(TRICK_CPPFLAGS) -c $<
MM_declare_var_unittest.o : MM_declare_var_unittest.cc
$(TRICK_CXX) $(TRICK_CPPFLAGS) -c $<
MM_stl_restore.o : MM_stl_testbed.hh MM_test.hh
MM_stl_checkpoint.o : MM_stl_testbed.hh MM_test.hh
MM_declare_var_2_unittest.o : MM_declare_var_2_unittest.cc
$(TRICK_CXX) $(TRICK_CPPFLAGS) -c $<
MM_declare_extern_var_unittest.o : MM_declare_extern_var_unittest.cc
$(TRICK_CXX) $(TRICK_CPPFLAGS) -c $<
MM_delete_var_unittest.o : MM_delete_var_unittest.cc
$(TRICK_CXX) $(TRICK_CPPFLAGS) -c $<
MM_ref_attributes_unittest.o : MM_ref_attributes_unittest.cc
$(TRICK_CXX) $(TRICK_CPPFLAGS) -c $<
MM_resize_array_unittest.o : MM_resize_array_unittest.cc
$(TRICK_CXX) $(TRICK_CPPFLAGS) -c $<
MM_strdup_unittest.o : MM_strdup_unittest.cc
$(TRICK_CXX) $(TRICK_CPPFLAGS) -c $<
MM_write_var_unittest.o : MM_write_var_unittest.cc
$(TRICK_CXX) $(TRICK_CPPFLAGS) -c $<
MM_sizeof_type_unittest.o : MM_sizeof_type_unittest.cc
$(TRICK_CXX) $(TRICK_CPPFLAGS) -c $<
MM_read_checkpoint.o : MM_read_checkpoint.cc
$(TRICK_CXX) $(TRICK_CPPFLAGS) -c $<
MM_clear_var_unittest.o : MM_clear_var_unittest.cc
$(TRICK_CXX) $(TRICK_CPPFLAGS) -c $<
MM_alloc_deps.o : MM_alloc_deps.cc
$(TRICK_CXX) $(TRICK_CPPFLAGS) -c $<
MM_write_checkpoint.o : MM_write_checkpoint.cc
$(TRICK_CXX) $(TRICK_CPPFLAGS) -c $<
MM_get_enumerated.o : MM_get_enumerated.cc
$(TRICK_CXX) $(TRICK_CPPFLAGS) -c $<
MM_ref_name_from_address.o : MM_ref_name_from_address.cc
$(TRICK_CXX) $(TRICK_CPPFLAGS) -c $<
MM_write_checkpoint_hexfloat.o : MM_write_checkpoint_hexfloat.cc
$(TRICK_CXX) $(TRICK_CPPFLAGS) -c $<
Bitfield_tests.o : Bitfield_tests.cpp
$(TRICK_CXX) $(TRICK_CPPFLAGS) -c $<
MM_stl_restore.o : MM_stl_restore.cc MM_stl_testbed.hh MM_test.hh $(STL_CHECKPOINT_DEPS)
$(TRICK_CXX) $(TRICK_CPPFLAGS) -c $<
MM_stl_checkpoint.o : MM_stl_checkpoint.cc MM_stl_testbed.hh MM_test.hh $(STL_CHECKPOINT_DEPS)
$(TRICK_CXX) $(TRICK_CPPFLAGS) -c $<
MM_creation_unittest : MM_creation_unittest.o
# ==================================================================================
# Build Unit test programs
# ==================================================================================
$(TESTS) : %: %.o
$(TRICK_CXX) $(TRICK_SYSTEM_LDFLAGS) -o $@ $^ -L${TRICK_HOME}/lib_${TRICK_HOST_CPU} $(TRICK_LIBS) $(TRICK_EXEC_LINK_LIBS)
MM_declare_var_unittest : MM_declare_var_unittest.o io_MM_user_defined_types.o
$(TRICK_CXX) $(TRICK_SYSTEM_LDFLAGS) -o $@ $^ -L${TRICK_HOME}/lib_${TRICK_HOST_CPU} $(TRICK_LIBS) $(TRICK_EXEC_LINK_LIBS)
MM_declare_var_2_unittest : MM_declare_var_2_unittest.o io_MM_user_defined_types.o
$(TRICK_CXX) $(TRICK_SYSTEM_LDFLAGS) -o $@ $^ -L${TRICK_HOME}/lib_${TRICK_HOST_CPU} $(TRICK_LIBS) $(TRICK_EXEC_LINK_LIBS)
MM_declare_extern_var_unittest : MM_declare_extern_var_unittest.o io_MM_user_defined_types.o
$(TRICK_CXX) $(TRICK_SYSTEM_LDFLAGS) -o $@ $^ -L${TRICK_HOME}/lib_${TRICK_HOST_CPU} $(TRICK_LIBS) $(TRICK_EXEC_LINK_LIBS)
MM_delete_var_unittest : MM_delete_var_unittest.o
$(TRICK_CXX) $(TRICK_SYSTEM_LDFLAGS) -o $@ $^ -L${TRICK_HOME}/lib_${TRICK_HOST_CPU} $(TRICK_LIBS) $(TRICK_EXEC_LINK_LIBS)
MM_ref_attributes_unittest : MM_ref_attributes_unittest.o io_MM_user_defined_types.o
$(TRICK_CXX) $(TRICK_SYSTEM_LDFLAGS) -o $@ $^ -L${TRICK_HOME}/lib_${TRICK_HOST_CPU} $(TRICK_LIBS) $(TRICK_EXEC_LINK_LIBS)
MM_resize_array_unittest : MM_resize_array_unittest.o io_MM_user_defined_types.o
$(TRICK_CXX) $(TRICK_SYSTEM_LDFLAGS) -o $@ $^ -L${TRICK_HOME}/lib_${TRICK_HOST_CPU} $(TRICK_LIBS) $(TRICK_EXEC_LINK_LIBS)
MM_strdup_unittest : MM_strdup_unittest.o
$(TRICK_CXX) $(TRICK_SYSTEM_LDFLAGS) -o $@ $^ -L${TRICK_HOME}/lib_${TRICK_HOST_CPU} $(TRICK_LIBS) $(TRICK_EXEC_LINK_LIBS)
MM_write_var_unittest : MM_write_var_unittest.o io_MM_user_defined_types.o
$(TRICK_CXX) $(TRICK_SYSTEM_LDFLAGS) -o $@ $^ -L${TRICK_HOME}/lib_${TRICK_HOST_CPU} $(TRICK_LIBS) $(TRICK_EXEC_LINK_LIBS)
MM_sizeof_type_unittest : MM_sizeof_type_unittest.o io_MM_user_defined_types.o
$(TRICK_CXX) $(TRICK_SYSTEM_LDFLAGS) -o $@ $^ -L${TRICK_HOME}/lib_${TRICK_HOST_CPU} $(TRICK_LIBS) $(TRICK_EXEC_LINK_LIBS)
MM_read_checkpoint : MM_read_checkpoint.o io_MM_user_defined_types.o
$(TRICK_CXX) $(TRICK_SYSTEM_LDFLAGS) -o $@ $^ -L${TRICK_HOME}/lib_${TRICK_HOST_CPU} $(TRICK_LIBS) $(TRICK_EXEC_LINK_LIBS)
MM_clear_var_unittest : MM_clear_var_unittest.o io_MM_user_defined_types.o
$(TRICK_CXX) $(TRICK_SYSTEM_LDFLAGS) -o $@ $^ -L${TRICK_HOME}/lib_${TRICK_HOST_CPU} $(TRICK_LIBS) $(TRICK_EXEC_LINK_LIBS)
MM_alloc_deps : MM_alloc_deps.o io_MM_alloc_deps.o
$(TRICK_CXX) $(TRICK_SYSTEM_LDFLAGS) -o $@ $^ -L${TRICK_HOME}/lib_${TRICK_HOST_CPU} $(TRICK_LIBS) $(TRICK_EXEC_LINK_LIBS)
MM_write_checkpoint : MM_write_checkpoint.o io_MM_write_checkpoint.o
$(TRICK_CXX) $(TRICK_SYSTEM_LDFLAGS) -o $@ $^ -L${TRICK_HOME}/lib_${TRICK_HOST_CPU} $(TRICK_LIBS) $(TRICK_EXEC_LINK_LIBS)
MM_get_enumerated : MM_get_enumerated.o io_MM_get_enumerated.o
$(TRICK_CXX) $(TRICK_SYSTEM_LDFLAGS) -o $@ $^ -L${TRICK_HOME}/lib_${TRICK_HOST_CPU} $(TRICK_LIBS) $(TRICK_EXEC_LINK_LIBS)
MM_ref_name_from_address : MM_ref_name_from_address.o io_MM_ref_name_from_address.o
$(TRICK_CXX) $(TRICK_SYSTEM_LDFLAGS) -o $@ $^ -L${TRICK_HOME}/lib_${TRICK_HOST_CPU} $(TRICK_LIBS) $(TRICK_EXEC_LINK_LIBS)
MM_write_checkpoint_hexfloat : MM_write_checkpoint_hexfloat.o io_MM_write_checkpoint.o
$(TRICK_CXX) $(TRICK_SYSTEM_LDFLAGS) -o $@ $^ -L${TRICK_HOME}/lib_${TRICK_HOST_CPU} $(TRICK_LIBS) $(TRICK_EXEC_LINK_LIBS)
Bitfield_tests : Bitfield_tests.o
$(TRICK_CXX) $(TRICK_SYSTEM_LDFLAGS) -o $@ $^ -L${TRICK_HOME}/lib_${TRICK_HOST_CPU} $(TRICK_LIBS) $(TRICK_EXEC_LINK_LIBS)
MM_stl_restore : MM_stl_restore.o io_MM_stl_testbed.o
$(TRICK_CXX) $(TRICK_SYSTEM_LDFLAGS) -o $@ $^ -L${TRICK_HOME}/lib_${TRICK_HOST_CPU} $(TRICK_LIBS) $(TRICK_EXEC_LINK_LIBS)
MM_stl_checkpoint : MM_stl_checkpoint.o io_MM_stl_testbed.o
$(TRICK_CXX) $(TRICK_SYSTEM_LDFLAGS) -o $@ $^ -L${TRICK_HOME}/lib_${TRICK_HOST_CPU} $(TRICK_LIBS) $(TRICK_EXEC_LINK_LIBS)
# ----------------------------------------------------------------------------------
# The following unittest programs are also dependent on the indicated object files.
# ----------------------------------------------------------------------------------
MM_declare_var_unittest : io_MM_user_defined_types.o
MM_declare_var_2_unittest : io_MM_user_defined_types.o
MM_declare_extern_var_unittest : io_MM_user_defined_types.o
MM_ref_attributes_unittest : io_MM_user_defined_types.o
MM_resize_array_unittest : io_MM_user_defined_types.o
MM_write_var_unittest : io_MM_user_defined_types.o
MM_sizeof_type_unittest : io_MM_user_defined_types.o
MM_read_checkpoint : io_MM_user_defined_types.o
MM_clear_var_unittest : io_MM_user_defined_types.o
MM_alloc_deps : io_MM_alloc_deps.o
MM_write_checkpoint : io_MM_write_checkpoint.o
MM_ref_name_from_address : io_MM_ref_name_from_address.o
MM_get_enumerated : io_MM_get_enumerated.o
MM_write_checkpoint_hexfloat : io_MM_write_checkpoint.o
MM_stl_restore : io_MM_stl_testbed.o
MM_stl_checkpoint : io_MM_stl_testbed.o

View File

@ -17,8 +17,8 @@ const char* trickTypeCharString( TRICK_TYPE type, const char* name) {
case TRICK_UNSIGNED_LONG: type_spec = "unsigned long"; break;
case TRICK_FLOAT: type_spec = "float"; break;
case TRICK_DOUBLE: type_spec = "double"; break;
case TRICK_BITFIELD: type_spec = "TRICK_BITFIELD";
case TRICK_UNSIGNED_BITFIELD: type_spec = "TRICK_UNSIGNED_BITFIELD";
case TRICK_BITFIELD: type_spec = "TRICK_BITFIELD"; break;
case TRICK_UNSIGNED_BITFIELD: type_spec = "TRICK_UNSIGNED_BITFIELD"; break;
case TRICK_LONG_LONG: type_spec = "long long"; break;
case TRICK_UNSIGNED_LONG_LONG: type_spec = "unsigned long long"; break;
case TRICK_FILE_PTR: type_spec = "FILE*"; break;