-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTest_erase.cpp
More file actions
84 lines (63 loc) · 1.54 KB
/
Test_erase.cpp
File metadata and controls
84 lines (63 loc) · 1.54 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
//
// Created by ABacker on 10/13/2016
//
#include "FakeList.h"
#include <list>
#include <iostream>
using namespace std;
using namespace nini;
string_builder build() {
string_builder sb;
char *s = new char[15];
strcpy(s, "1234567890");
sb.assign(std::move(s), strlen(s));
sb.append("1234567890");
sb.insert("aacc", 4, 10);
sb.insert("ddeeff", 6, 4);
sb.insert("cccc", 4, 6);
auto it_insert = sb.begin();
it_insert += 4;
sb.insert("bbb", 3, it_insert);
sb.print(true);
return sb;
}
void test_erase1(int _L, int _R) {
printf("test_erase [%d,%d)\n", _L, _R);
string_builder sb = build();
size_type _Oldsize = sb.size();
string_builder::const_iterator _IterL = sb.begin(), _IterR = sb.begin();
for (int i = 0; i < _L; ++_IterL, ++i) {
}
for (int i = 0; i < _R; ++_IterR, ++i) {
}
sb.erase(_IterL, _IterR);
sb.print(true);
// check size
if (sb.size() != _Oldsize - (_R - _L)) {
throw 1;
}
}
void test_erase2(int _L, int _R) {
printf("test_erase [%d,%d)\n", _L, _R);
string_builder sb = build();
size_type _Oldsize = sb.size();
sb.erase(_L, _R - _L);
sb.print(true);
// check size
if (sb.size() != _Oldsize - (_R - _L)) {
throw 1;
}
}
int main() {
for (int i = 0; i < 37; ++i) {
for (int j = i; j < 38; ++j) {
test_erase1(i, j);
}
}
for (int i = 0; i < 37; ++i) {
for (int j = i; j < 38; ++j) {
test_erase2(i, j);
}
}
return 0;
}