13
13
14
14
using namespace TAP ;
15
15
16
- /* Test that dict works as expected*/
16
+ class StampTwoCharsList : public StampGeneric
17
+ {
18
+ protected:
19
+ StampTwoChars el_stamp;
20
+ GalleySeries galley;
21
+ public:
22
+ std::string ExtractStr (Blob &blob) override ;
23
+ StampTwoCharsList (): el_stamp {}, galley {el_stamp} {};
24
+ virtual bool isFixedSize () override {return false ;};
25
+ virtual int maxSize () override {return -1 ;};
26
+ virtual int minSize () override {return el_stamp.minSize ();};
27
+ };
28
+
29
+ std::string
30
+ StampTwoCharsList::ExtractStr (Blob &blob)
31
+ {
32
+ std::string res = " " ;
33
+ std::list<std::string> list = galley.Extract (blob);
34
+
35
+ for (std::string point : list)
36
+ {
37
+ if (!res.empty ()) res = res + " , " ;
38
+ res = res + point;
39
+ }
40
+
41
+ if (res.empty ()) return " " ;
42
+
43
+ res = " (" + res + " )" ;
44
+ return res;
45
+ }
46
+
17
47
18
48
char short_sample[]=" 1234567" ;
49
+ char longer_sample[]=" z1234567*89abcde&fghijklmnopqrstuvwxyzAB%CDEFGHIJKLMNOPQRSTUVWXYZ!" ;
19
50
20
51
int
21
52
main ()
22
53
{
23
- TEST_START (4 );
54
+ TEST_START (9 );
55
+ /* Test Galley Sereies with fixed size stampp*/
24
56
{ /* 1..4 */
25
57
std::string expected1 = " 12" ;
26
58
std::string expected2 = " 34" ;
@@ -34,18 +66,53 @@ main()
34
66
std::string str;
35
67
36
68
str = res.front ();
37
- ok (str == expected1, " GalleySeries: First element of shifted list is ok" );
69
+ is (str, expected1, " GalleySeries, fixed size stamp: First element of shifted list is ok" );
70
+ res.pop_front ();
71
+
72
+ str = res.front ();
73
+ is (str, expected2, " GalleySeries, fixed size stamp: Second element of shifted list is ok" );
74
+ res.pop_front ();
75
+
76
+ str = res.front ();
77
+ is (str, expected3, " GalleySeries, fixed size stamp: Third element of shifted list is ok" );
78
+ res.pop_front ();
79
+
80
+ ok (res.empty (), " GalleySeries, fixed size stamp: The rest of the list is empty" );
81
+ }
82
+ /* Test Galley Sereies with unlimited size stampp*/
83
+ { /* 5 .. 9*/
84
+ /* This is not the best test, as we do not predict behavior by setting forged sample values,
85
+ but at least here we check that it work the same way it worked before. May be this test should be improved later*/
86
+
87
+ std::string expected1 = " (9a, bc, de, &f, gh, ij)" ;
88
+ std::string expected2 = " (lm, no, pq, rs, tu, vw, xy)" ;
89
+ std::string expected3 = " (zA, B%, CD, EF, GH, IJ, KL)" ;
90
+ std::string expected4 = " (MN, OP, QR, ST, UV, WX, YZ)" ;
91
+
92
+ Blob blob (longer_sample, strlen (longer_sample));
93
+ StampTwoCharsList stamp_charlist;
94
+ GalleySeries galley (stamp_charlist);
95
+
96
+ std::list<std::string> res = galley.Extract (blob);
97
+ std::string str;
98
+
99
+ str = res.front ();
100
+ is (str, expected1, " GalleySeries, unlimited size stamp: First element of shifted list is ok" );
101
+ res.pop_front ();
102
+
103
+ str = res.front ();
104
+ is (str, expected2, " GalleySeries, unlimited size stamp: Second element of shifted list is ok" );
38
105
res.pop_front ();
39
106
40
107
str = res.front ();
41
- ok (str == expected2 , " GalleySeries: Second element of shifted list is ok" );
108
+ is (str, expected3 , " GalleySeries, unlimited size stamp: Third element of shifted list is ok" );
42
109
res.pop_front ();
43
110
44
111
str = res.front ();
45
- ok (str == expected3 , " GalleySeries: Third element of shifted list is ok" );
112
+ is (str, expected4 , " GalleySeries, unlimited size stamp: Fourth element of shifted list is ok" );
46
113
res.pop_front ();
47
114
48
- ok (res.empty (), " GalleySeries: The rest of the list is empty" );
115
+ ok (res.empty (), " GalleySeries, unlimited size stamp : The rest of the list is empty" );
49
116
}
50
117
51
118
TEST_END;
0 commit comments