-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_substring.cpp
More file actions
52 lines (40 loc) · 1 KB
/
test_substring.cpp
File metadata and controls
52 lines (40 loc) · 1 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
// String
//
// Tests: subscript, uses ==
//
// NEED TO IMPLEMENT
//
#include <iostream>
#include <cassert>
#include "string.hpp"
//===========================================================================
int main(){
{
String str = "hi mom";
String s1;
String s2;
s1 = str.substr(0,0);
s2 = str.substr(0,5);
std::cout << s1 << std::endl;
std::cout << s2 << std::endl;
assert(s1 == "h");
assert(s2 == "hi mom");
}
{
String str = "The quick brown fox jumps over the lazy dog";
String s1;
s1 = str.substr(0,8);
assert(s1 == "The quick");
}
{
String str = "The quick brown fox jumps over the lazy dog";
String s1;
String s2;
s1 = str.substr(0,2);
s2 = str.substr(16,18);
assert(s1 == "The");
std::cout << s2 << std::endl;
assert(s2 == "fox");
}
std::cout << "Done testing substr" << std::endl;
}