-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.cpp
63 lines (52 loc) · 1.52 KB
/
test.cpp
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
#include <iostream>
#include <stdio.h>
#include "mystring.h"
//tests from 1 to 5
#define TEST 2
int main() {
#if TEST == 1
MyString ms1("sample text");
MyString ms2 = ms1;
MyString ms3(ms1);
MyString ms4(ms2);
MyString ms5;
ms5 = ms4;
std::cout <<"ms1: " << ms1 << "\n" << "ms2: " << ms2 << "\n" << "ms3: "
<< ms3 << "\n" << "ms4: " << ms4 << "\n" << "ms5: " << ms5 << "\n" << "\n";
#endif
#if TEST == 2
std::cout << "--------------------------" << "\n";
MyString inputstr{};
std::cin >> inputstr;
std::cout << "user's input: " << inputstr << "\n";
#endif
#if TEST == 3
std::cout << "--------------------------" << "\n";
MyString a{"a"};
MyString plus{" + "};
MyString b{"b"};
MyString result;
result = a + plus + b;
std::cout << result << "\n";
result += " + c";
std::cout << result << "\n";
result = result + " = result";
std::cout << result << "\n";
MyString memleak{a + b};
std::cout << "'a' + 'b' = " << memleak << "\n";
#endif
#if TEST == 4
std::cout << "--------------------------" << "\n";
MyString index_test{"012345"};
index_test[3] = 'a';
std::cout << index_test << "\n";
#endif
#if TEST == 5
std::cout << "--------------------------" << "\n";
MyString something{"length"};
std::cout << "the length of the word 'length': " << something.length() << "\n";
#endif
std::cout << "--------------------------" << "\n";
//git test 2
return 0;
}