|
28 | 28 | char *ptr; |
29 | 29 | size_t size; |
30 | 30 |
|
31 | | -TEST_START(8); |
| 31 | +TEST_START(10); |
32 | 32 |
|
33 | 33 | /* Test that ShiftSingleStampStr shifts ok with StampTwoChars stamp*/ |
34 | 34 | {/* 1..3*/ |
@@ -82,10 +82,54 @@ main() |
82 | 82 |
|
83 | 83 | is(str,"12345678","variated size stamp shifts as much data as it can (take two)"); |
84 | 84 |
|
85 | | - str = blob.ShiftSingleStampStr(stamp); |
86 | | -is(str,"","variated size stamp refuses to stamp when it is offered too few data"); |
| 85 | +try { |
| 86 | + std::string str = blob.ShiftSingleStampStr(stamp); |
| 87 | +ok(false,"Variated stamp, not enough data"); |
| 88 | + } |
| 89 | +catch (OutOfData) |
| 90 | + { |
| 91 | +ok(true,"Variated stamp, not enough data"); |
| 92 | + } |
| 93 | +catch (...)//Any other exeption |
| 94 | + { |
| 95 | +ok(false,"Variated stamp, not enough data"); |
| 96 | + } |
87 | 97 | } |
88 | 98 |
|
| 99 | + {/* 9*/ |
| 100 | +char sample[]="1"; |
| 101 | + Blobblob(sample,strlen(sample)); |
| 102 | + StampTwoChars stamp; |
| 103 | +try { |
| 104 | + std::string str = blob.ShiftSingleStampStr(stamp); |
| 105 | +ok(false,"Fixed stamp, not enough data"); |
| 106 | + } |
| 107 | +catch (OutOfData) |
| 108 | + { |
| 109 | +ok(true,"Fixed stamp, not enough data"); |
| 110 | + } |
| 111 | +catch (...)//Any other exeption |
| 112 | + { |
| 113 | +ok(false,"Fixed stamp, not enough data"); |
| 114 | + } |
| 115 | + } |
89 | 116 |
|
| 117 | + {/* 10*/ |
| 118 | +char sample[]="1"; |
| 119 | + Blobblob(sample,strlen(sample)); |
| 120 | + StampTwoCharsList stamp; |
| 121 | +try { |
| 122 | + std::string str = blob.ShiftSingleStampStr(stamp); |
| 123 | +ok(false,"Unbounded stamp, not enough data"); |
| 124 | + } |
| 125 | +catch (OutOfData) |
| 126 | + { |
| 127 | +ok(true,"Unbounded stamp, not enough data"); |
| 128 | + } |
| 129 | +catch (...)//Any other exeption |
| 130 | + { |
| 131 | +ok(false,"Unbounded stamp, not enough data"); |
| 132 | + } |
| 133 | + } |
90 | 134 | TEST_END; |
91 | 135 | } |