-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathtestStringTemplate.cpp
72 lines (59 loc) · 1.29 KB
/
testStringTemplate.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
64
65
66
67
68
69
70
71
72
#include "StringTemplate.h"
#include <cassert>
int main(int argc, char *argv[])
{
std::string ret;
StringTemplate t1("");
std::string e1 = "";
assert( 0 == t1.translate(&ret));
assert( ret == e1);
t1 = "a";
e1 = "a";
assert( 0 == t1.translate(&ret));
assert( ret == e1);
t1 = "01$(a)34";
e1 = "01234";
t1.add("a", "2");
assert( 0 == t1.translate(&ret));
assert( ret == e1);
t1 = "01$[a]34";
e1 = "01a34";
assert( 0 == t1.translate(&ret));
assert( ret == e1);
t1 = "01$[23$(a)56]78";
e1 = "012345678";
t1.add("a", "4");
assert( 0 == t1.translate(&ret));
assert( ret == e1);
t1 = "01$[$(a)]45";
e1 = "012345";
std::vector<std::string> a;
a.push_back("2");
a.push_back("3");
t1.add("a", a);
assert( 0 == t1.translate(&ret));
assert( ret == e1);
t1 = "0,1,$[$(a) ,],4,5";
e1 = "0,1,2,3,4,5";
a.clear();
a.push_back("2");
a.push_back("3");
t1.add("a", a);
assert( 0 == t1.translate(&ret));
assert( ret == e1);
t1 = "$[$(a) ,],$[$(b) ,],$(c)";
e1 = "0,1,2,3,4,5";
a.clear();
a.push_back("0");
a.push_back("1");
t1.add("a", a);
std::vector<std::string> b;
b.push_back("2");
b.push_back("3");
b.push_back("4");
t1.add("b", b);
t1.add("c", "5");
assert( 0 == t1.translate(&ret));
assert( ret == e1);
return 0;
}