@@ -17,8 +17,8 @@ char longer_sample[]="z1234567*89abcde&fghijklmnopqrstuvwxyzAB%CDEFGHIJKLMNOPQRS
17
17
18
18
int
19
19
main ()
20
- {
21
- TEST_START (53 );
20
+ {
21
+ TEST_START (63 );
22
22
/* Test Galley Sereies with fixed size stampp*/
23
23
{ /* 1..4 */
24
24
std::string expected1 = " 12" ;
@@ -172,7 +172,6 @@ main()
172
172
173
173
std::vector<std::string> res = galley.ExtractStr (blob);
174
174
std::string str;
175
-
176
175
str = res[0 ];
177
176
is (str, expected1, " GalleyVector, fixed size string stamps: First element of vector is ok" );
178
177
@@ -356,5 +355,92 @@ main()
356
355
is (galley.maxSize (), -1 , " GalleyVector, mixed types stamps 2: galley max size is ok" );
357
356
}
358
357
358
+ /* Test Galley Vector, when there are only minimal amound of data available */
359
+ { /* 54 .. 63*/
360
+
361
+ char sample[] = " oo" " oo" " oo" " oo" " oo" " z1" " 23" " 45" " 67" " 89" " ab" ;
362
+
363
+ std::string expected1 = " (z1)" ; // first u_stamp
364
+ std::string expected2 = " 23" ; // first v_stamp
365
+ std::string expected3 = " 45" ; // second v_stamp
366
+ std::string expected4 = " 67" ; // first f_stamp
367
+ std::string expected5 = " (89)" ; // second u_stamp
368
+ std::string expected6 = " ab" ; // second f_stamp
369
+
370
+ Blob blob (sample, strlen (sample));
371
+
372
+ StampTwoChars f_stamp;
373
+ StampSeveralChars v_stamp;
374
+ StampTwoCharsList u_stamp;
375
+
376
+ std::vector<std::reference_wrapper<StampBase>> stamps;
377
+ stamps.push_back (u_stamp);
378
+ stamps.push_back (v_stamp);
379
+ stamps.push_back (v_stamp);
380
+ stamps.push_back (f_stamp);
381
+ stamps.push_back (u_stamp);
382
+ stamps.push_back (f_stamp);
383
+
384
+ GalleyVector galley (stamps);
385
+
386
+ std::vector<std::string> res = galley.ExtractStr (blob);
387
+ std::string str;
388
+
389
+ str = res[0 ];
390
+ is (str, expected1, " GalleyVector, mixed type stamps 3: First unbounded stamp is ok" );
391
+
392
+ str = res[1 ];
393
+ is (str, expected2, " GalleyVector, mixed type stamps 3: Fist varieded stamp is ok" );
394
+
395
+ str = res[2 ];
396
+ is (str, expected3, " GalleyVector, mixed type stamps 3: Second variated stamp is ok" );
397
+
398
+ str = res[3 ];
399
+ is (str, expected4, " GalleyVector, mixed type stamps 3: First fixed stamp is ok" );
400
+
401
+ str = res[4 ];
402
+ is (str, expected5, " GalleyVector, mixed type stamps 3: Second unbounded stamp is ok" );
403
+
404
+ str = res[5 ];
405
+ is (str, expected6, " GalleyVector, mixed type stamps 3: Second fixed stamp is ok" );
406
+
407
+ is (res.size (), 6 , " GalleyVector, mixed type stamps 3: The vector has only six elements " );
408
+
409
+ is (blob.Size (), 0 , " GalleyVector 3: will use all data if we have at least one unbounded stamp" );
410
+
411
+ is (galley.minSize (), (f_stamp.minSize ()+v_stamp.minSize ()+u_stamp.minSize ())*2 + ORACLE_SIZE * (2 +2 +1 ), " GalleyVector, mixed types stamps 3: galley min size is ok" );
412
+ is (galley.maxSize (), -1 , " GalleyVector, mixed types stamps 3: galley max size is ok" );
413
+ }
414
+
415
+ /* Test Galley Vector, when there are not enought data */
416
+ { /* 64 .. 67*/
417
+
418
+ char sample[] = " oo" " oo" " oo" " oo" " oo" " z1" " 23" " 45" " 67" " 89" " a" ;
419
+
420
+ Blob blob (sample, strlen (sample));
421
+
422
+ StampTwoChars f_stamp;
423
+ StampSeveralChars v_stamp;
424
+ StampTwoCharsList u_stamp;
425
+
426
+ std::vector<std::reference_wrapper<StampBase>> stamps;
427
+ stamps.push_back (u_stamp);
428
+ stamps.push_back (v_stamp);
429
+ stamps.push_back (v_stamp);
430
+ stamps.push_back (f_stamp);
431
+ stamps.push_back (u_stamp);
432
+ stamps.push_back (f_stamp);
433
+
434
+ GalleyVector galley (stamps);
435
+ std::vector<std::string> res = galley.ExtractStr (blob);
436
+ std::string str;
437
+
438
+ is (res.size (), 0 , " GalleyVector, mixed type stamps 4: Fails when not enught data" );
439
+
440
+ is (blob.Size (), strlen (sample) , " GalleyVector 4: will use keep all data when applying galley fails" );
441
+
442
+ is (galley.minSize (), (f_stamp.minSize ()+v_stamp.minSize ()+u_stamp.minSize ())*2 + ORACLE_SIZE * (2 +2 +1 ), " GalleyVector, mixed types stamps 4: galley min size is ok" );
443
+ is (galley.maxSize (), -1 , " GalleyVector, mixed types stamps 4: galley max size is ok" );
444
+ }
359
445
TEST_END;
360
446
}
0 commit comments