@@ -18,7 +18,7 @@ char longer_sample[]="z1234567*89abcde&fghijklmnopqrstuvwxyzAB%CDEFGHIJKLMNOPQRS
1818int
1919main ()
2020{
21- TEST_START (18 );
21+ TEST_START (46 );
2222/* Test Galley Sereies with fixed size stampp*/
2323 {/* 1..4*/
2424 std::string expected1 =" 12" ;
@@ -149,10 +149,170 @@ main()
149149 res.pop_front ();
150150
151151ok (res.empty ()," GalleySeries, unlimited size string stamp: The rest of the list is empty" );
152+
153+ }
154+
155+ /* Test Galley Vector with fixed size stamps*/
156+ {/* 19 .. 22*/
157+
158+ char sample[]=" z1234567*89abcde&fghijklm" ;
159+
160+ std::string expected1 =" z1" ;
161+ std::string expected2 =" 23" ;
162+
163+
164+ Blobblob (sample,strlen (sample));
165+
166+ StampTwoChars stamp;
167+ std::vector<std::reference_wrapper<StampBase>> stamps;
168+ stamps.push_back (stamp);
169+ stamps.push_back (stamp);
170+
171+ GalleyVectorgalley (stamps);
172+
173+ std::vector<std::string> res = galley.ExtractStr (blob);
174+ std::string str;
175+
176+ str = res[0 ];
177+ is (str, expected1," GalleyVector, fixed size string stamps: First element of vector is ok" );
178+
179+ str = res[1 ];
180+ is (str, expected2," GalleyVector, fixed size string stamps: Second element of vector is ok" );
181+
182+ is (res.size (),2 ," GalleyVector, fixed size string stamps: The vector has only two elements" );
183+
184+ is (blob.Size (),strlen (sample) - res[0 ].length () - res[1 ].length ()," GalleyVector: shifts no extra bytes for fixed stamps" );
185+
186+ is (galley.minSize (), stamp.minSize ()*2 ," GalleyVector, fixed size string stamps: galley min size is ok" );
187+ is (galley.maxSize (), stamp.maxSize ()*2 ," GalleyVector, fixed size string stamps: galley max size is ok" );
188+ }
189+
190+ /* Test Galley Vector with variated size stamps*/
191+ {/* 25 .. 30*/
192+
193+ char sample[]=" z1234567*89abcde&fghijklm" ;
194+
195+ std::string expected1 =" 456" ;
196+ std::string expected2 =" 7*8" ;
197+
198+ Blobblob (sample,strlen (sample));
199+
200+ StampSeveralChars stamp;
201+ std::vector<std::reference_wrapper<StampBase>> stamps;
202+ stamps.push_back (stamp);
203+ stamps.push_back (stamp);
204+
205+ GalleyVectorgalley (stamps);
206+
207+ std::vector<std::string> res = galley.ExtractStr (blob);
208+ std::string str;
209+
210+ str = res[0 ];
211+ is (str, expected1," GalleyVector, variated size string stamp: First element of vector is ok" );
212+
213+ str = res[1 ];
214+ is (str, expected2," GalleyVector, variated size string stamp: Second element of vector is ok" );
215+
216+ is (res.size (),2 ," GalleyVector, variated size string stamp: The vector has only two elements" );
217+
218+ is (blob.Size (),strlen (sample) - res[0 ].length () - res[1 ].length () - ORACLE_SIZE*2 ," GalleyVector: shifts one oracle for each variated stamps" );
219+
220+ is (galley.minSize (), stamp.minSize ()*2 + ORACLE_SIZE *2 ," GalleyVector, variated size string stamps: galley min size is ok" );
221+ is (galley.maxSize (), stamp.maxSize ()*2 + ORACLE_SIZE *2 ," GalleyVector, variated size string stamps: galley max size is ok" );
222+ }
223+
224+ /* Test Galley Vector with unbounded size stamps*/
225+ {/* 31 .. 36*/
226+
227+ char sample[]=" z1234567*89abcde&fghijklm" ;
228+
229+ std::string expected1 =" (45, 67, *8, 9a, bc)" ;
230+ std::string expected2 =" (de, &f, gh, ij, kl)" ;
231+
232+ Blobblob (sample,strlen (sample));
233+
234+ StampTwoCharsList stamp;
235+ std::vector<std::reference_wrapper<StampBase>> stamps;
236+ stamps.push_back (stamp);
237+ stamps.push_back (stamp);
238+
239+ GalleyVectorgalley (stamps);
240+
241+ std::vector<std::string> res = galley.ExtractStr (blob);
242+ std::string str;
243+
244+ str = res[0 ];
245+ is (str, expected1," GalleyVector, unbounded size string stamp: First element of vector is ok" );
246+
247+ str = res[1 ];
248+ is (str, expected2," GalleyVector, unbounded size string stamp: Second element of vector is ok" );
249+
250+ is (res.size (),2 ," GalleyVector, unbounded size string stamp: The vector has only two elements" );
251+
252+ is (blob.Size (),0 ," GalleyVector: will use all data for unbounded stamp" );
253+
254+ is (galley.minSize (), stamp.minSize ()*2 + ORACLE_SIZE *2 ," GalleyVector, unbounded size string stamps: galley min size is ok" );
255+ is (galley.maxSize (), -1 ," GalleyVector, unbounded size string stamps: galley max size is ok" );
256+
152257 }
153258
259+ /* Test Galley Vector with mixed stam types*/
260+ {/* 37 .. 46*/
154261
262+ char sample[]=" z1234567*89abcde&fghijklmnopqrstuvwxyzAB%CDEFGHIJKLMNOPQRSTUVWXYZ!" ;
155263
264+ std::string expected1 =" (9a, bc, de, &f, gh, ij, kl, mn, op, qr, st)" ;// first u_stamp
265+ std::string expected2 =" uvw" ;// first v_stamp
266+ std::string expected3 =" xyzA" ;// second v_stamp
267+ std::string expected4 =" B%" ;// first f_stamp
268+ std::string expected5 =" (CD, EF, GH, IJ, KL, MN, OP, QR, ST, UV, WX)" ;// second u_stamp
269+ std::string expected6 =" Z!" ;// second f_stamp
270+
271+ Blobblob (sample,strlen (sample));
272+
273+
274+ StampTwoChars f_stamp;
275+ StampSeveralChars v_stamp;
276+ StampTwoCharsList u_stamp;
277+
278+ std::vector<std::reference_wrapper<StampBase>> stamps;
279+ stamps.push_back (u_stamp);
280+ stamps.push_back (v_stamp);
281+ stamps.push_back (v_stamp);
282+ stamps.push_back (f_stamp);
283+ stamps.push_back (u_stamp);
284+ stamps.push_back (f_stamp);
285+
286+ GalleyVectorgalley (stamps);
287+
288+ std::vector<std::string> res = galley.ExtractStr (blob);
289+ std::string str;
290+
291+ str = res[0 ];
292+ is (str, expected1," GalleyVector, mixed type stamps: First unbounded stamp is ok" );
293+
294+ str = res[1 ];
295+ is (str, expected2," GalleyVector, mixed type stamps: Fist varieded stamp is ok" );
296+
297+ str = res[2 ];
298+ is (str, expected3," GalleyVector, mixed type stamps: Second variated stamp is ok" );
299+
300+ str = res[3 ];
301+ is (str, expected4," GalleyVector, mixed type stamps: First fixed stamp is ok" );
302+
303+ str = res[4 ];
304+ is (str, expected5," GalleyVector, mixed type stamps: Second unbounded stamp is ok" );
305+
306+ str = res[5 ];
307+ is (str, expected6," GalleyVector, mixed type stamps: Second fixed stamp is ok" );
308+
309+ is (res.size (),6 ," GalleyVector, mixed type stamps: The vector has only six elements" );
310+
311+ is (blob.Size (),0 ," GalleyVector: will use all data if we have at least one unbounded stamp" );
312+
313+ is (galley.minSize (), (f_stamp.minSize ()+v_stamp.minSize ()+u_stamp.minSize ())*2 + ORACLE_SIZE * (2 +2 +1 )," GalleyVector, mixed types stamps: galley min size is ok" );
314+ is (galley.maxSize (), -1 ," GalleyVector, mixed types stamps: galley max size is ok" );
315+ }
156316
157317 TEST_END;
158318}