1313
1414using namespace TAP ;
1515
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::stringExtractStr (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+
1747
1848char short_sample[]=" 1234567" ;
49+ char longer_sample[]=" z1234567*89abcde&fghijklmnopqrstuvwxyzAB%CDEFGHIJKLMNOPQRSTUVWXYZ!" ;
1950
2051int
2152main ()
2253{
23- TEST_START (4 );
54+ TEST_START (9 );
55+ /* Test Galley Sereies with fixed size stampp*/
2456 {/* 1..4*/
2557 std::string expected1 =" 12" ;
2658 std::string expected2 =" 34" ;
@@ -34,18 +66,53 @@ main()
3466 std::string str;
3567
3668 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+ Blobblob (longer_sample,strlen (longer_sample));
93+ StampTwoCharsList stamp_charlist;
94+ GalleySeriesgalley (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" );
38105 res.pop_front ();
39106
40107 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" );
42109 res.pop_front ();
43110
44111 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" );
46113 res.pop_front ();
47114
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" );
49116 }
50117
51118 TEST_END;