-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainTrain.cpp
More file actions
113 lines (87 loc) · 2.41 KB
/
MainTrain.cpp
File metadata and controls
113 lines (87 loc) · 2.41 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#define _CRT_SECURE_NO_WARNINGS
#include "Str.h"
#include <iostream>
#include <string.h>
using namespace std;
int main()
{
//1
Str s1;
if (0 != strcmp(s1.getStr(), "none"))
cout << "Error creating empty Str (-5)" << endl;
//4
const char* tmp = "test str";
Str s4(tmp);
if (s4.getStr() == tmp)
cout << "Error creating Str from char* (-5)" << endl;
if (0 != strcmp(s4.getStr(), tmp))
cout << "Error creating Str from char* (-5)" << endl;
//3
Str s3(s4);
if (s3.getStr() == s4.getStr())
cout << "Error creating Str from Str (-5)" << endl;
if (0 != strcmp(s3.getStr(), s4.getStr()))
cout << "Error creating Str from Str (-5)" << endl;
//5
if (s3 == s1)
cout << "Error in operator== (-5)" << endl;
//6
if( s3 != s4 )
cout << "Error in operator!= (-5)" << endl;
//7
if( s3 < s1 )
cout << "Error in operator< (-5)" << endl;
//8
if( s1 > s3 )
cout << "Error in operator> (-5)" << endl;
//9
s4 = s1;
if( s1.getStr() == s4.getStr() )
cout << "Error in operator= (-5)" << endl;
if( 0 != strcmp( s1.getStr(), s4.getStr() ) )
cout << "Error in operator= (-5)" << endl;
//10
const char* tmp2 = "test str2";
s4 = tmp2;
if( s4.getStr() == tmp2 )
cout << "Error in operator= (-5)" << endl;
if( 0 != strcmp( s4.getStr(), tmp2 ) )
cout << "Error in operator= (-5)" << endl;
//11
if( s4[2] != 's' )
cout << "Error in operator[] (-5)" << endl;
//12
++s4;
if( s4[2] != 't' )
cout << "Error in operator++ (-5)" << endl;
//13
if( s4++[2] != 't' )
cout << "Error in operator++(int) (-5)" << endl;
if( s4[2] != 'u' )
cout << "Error in operator++(int) (-5)" << endl;
//14
if( int( s1 ) != 4 )
cout << "Error in operator int (cast) (-5)" << endl;
//15
if( s1( 'n' ) != 0 )
cout << "Error in operator() (-5)" << endl;
//16
s1 = s1 + s3;
if( 0 != strcmp( s1.getStr(), "nonetest str" ) )
cout << "Error in operator+(Str) (-5)" << endl;
//17
s3 = "this is " + s3;
if( 0 != strcmp( s3.getStr(), "this is test str" ) )
cout << "Error in operator+(Str) (-5)" << endl;
//18
Str s5( "boom" );
Str s6 = 3 * s5;
if( 0 != strcmp( s6.getStr(), "boomboomboom" ) )
cout << "Error in operator* (-5)" << endl;
//19
s3 += s5;
if( 0 != strcmp( s3.getStr(), "this is test strboom" ) )
cout << "Error in operator+= (-5)" << endl;
cout << "done" << endl;
return 0;
}