-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_driver.cpp
More file actions
69 lines (59 loc) · 3.02 KB
/
test_driver.cpp
File metadata and controls
69 lines (59 loc) · 3.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*
* File: test_driver.h
* Author: akkas
*
* Created on December 9, 2014, 2:35 AM
*/
#include "test_driver.h"
#include "test_cases.h"
#include <iostream>
test_driver::test_driver(void) : total_passed_tests(0), total_failed_tests(0){
add_test();
}
test_driver::~test_driver(void){
}
void test_driver::add_test(){
test_cases tests;
test_list.push_back([&]() { return tests.empty_string_default_constructor();});
test_list.push_back([&]() { return tests.char_to_string_constructor(); });
test_list.push_back([&]() { return tests.char_to_string_lenght_constructor();});
test_list.push_back([&]() { return tests.correct_data_copy_constructor();});
test_list.push_back([&]() { return tests.assignment_operator();});
test_list.push_back([&]() { return tests.assignment_operator_string_length();});
test_list.push_back([&]() { return tests.subscript_operator_for_valid_index();});
test_list.push_back([&]() { return tests.subscript_operator_for_negative_index();});
test_list.push_back([&]() { return tests.subscript_operator_for_set_value();});
test_list.push_back([&]() { return tests.swap_strings();});
test_list.push_back([&]() { return tests.size_for_empty_string();});
test_list.push_back([&]() { return tests.size_for_valid_string();});
test_list.push_back([&]() { return tests.check_to_string_char();});
test_list.push_back([&]() { return tests.check_to_string_char_for_empty_string();});
test_list.push_back([&]() { return tests.push_back_to_string();});
test_list.push_back([&]() { return tests.push_back_to_string_check_length();});
test_list.push_back([&]() { return tests.push_back_to_empty_string();});
test_list.push_back([&]() { return tests.pop_back_from_string();});
test_list.push_back([&]() { return tests.pop_back_from_string_check_string();});
test_list.push_back([&]() { return tests.pop_back_from_string_check_length();});
test_list.push_back([&]() { return tests.pop_back_from_empty_string();});
test_list.push_back([&]() { return tests.erase_with_valid_index();});
test_list.push_back([&]() { return tests.erase_with_invalid_index();});
test_list.push_back([&]() { return tests.insert_to_start_of_string();});
test_list.push_back([&]() { return tests.insert_to_middle_of_string();});
test_list.push_back([&]() { return tests.insert_to_end_of_string();});
test_list.push_back([&]() { return tests.string_out_put_operator();});
test_list.push_back([&]() { return tests.string_input_operator();});
test_list.push_back([&]() { return tests.string_input_operator_check_length();});
}
void test_driver::start_testing(){
for(auto it = test_list.begin(); it != test_list.end(); it++){
try{
(*it)();
total_passed_tests++;
}
catch(...){
total_failed_tests++;
}
}
std::cout<<"Passed tests\t"<<total_passed_tests<<std::endl;
std::cout<<"Failed tests\t"<<total_failed_tests<<std::endl;
}