summaryrefslogtreecommitdiff
path: root/xdelta3/xdelta3-test.h
diff options
context:
space:
mode:
Diffstat (limited to 'xdelta3/xdelta3-test.h')
-rw-r--r--xdelta3/xdelta3-test.h33
1 files changed, 28 insertions, 5 deletions
diff --git a/xdelta3/xdelta3-test.h b/xdelta3/xdelta3-test.h
index c19f2fd..7d7f6a0 100644
--- a/xdelta3/xdelta3-test.h
+++ b/xdelta3/xdelta3-test.h
@@ -925,6 +925,7 @@ static int sec_dist_func6 (xd3_stream *stream, xd3_output *data);
925static int sec_dist_func7 (xd3_stream *stream, xd3_output *data); 925static int sec_dist_func7 (xd3_stream *stream, xd3_output *data);
926static int sec_dist_func8 (xd3_stream *stream, xd3_output *data); 926static int sec_dist_func8 (xd3_stream *stream, xd3_output *data);
927static int sec_dist_func9 (xd3_stream *stream, xd3_output *data); 927static int sec_dist_func9 (xd3_stream *stream, xd3_output *data);
928static int sec_dist_func10 (xd3_stream *stream, xd3_output *data);
928 929
929static sec_dist_func sec_dists[] = 930static sec_dist_func sec_dists[] =
930{ 931{
@@ -937,6 +938,7 @@ static sec_dist_func sec_dists[] =
937 sec_dist_func7, 938 sec_dist_func7,
938 sec_dist_func8, 939 sec_dist_func8,
939 sec_dist_func9, 940 sec_dist_func9,
941 sec_dist_func10,
940}; 942};
941 943
942/* Test ditsribution: 100 bytes of the same character (13). */ 944/* Test ditsribution: 100 bytes of the same character (13). */
@@ -1089,6 +1091,21 @@ sec_dist_func9 (xd3_stream *stream, xd3_output *data)
1089 return 0; 1091 return 0;
1090} 1092}
1091 1093
1094/* Test distribution: freq[i] == i*i, creates a 21-bit code length, fixed in 3.0r. */
1095static int
1096sec_dist_func10 (xd3_stream *stream, xd3_output *data)
1097{
1098 int i, j, ret;
1099 for (i = 0; i < ALPHABET_SIZE; i += 1)
1100 {
1101 for (j = 0; j <= (i*i); j += 1)
1102 {
1103 if ((ret = xd3_emit_byte (stream, & data, i))) { return ret; }
1104 }
1105 }
1106 return 0;
1107}
1108
1092static int 1109static int
1093test_secondary_decode (xd3_stream *stream, 1110test_secondary_decode (xd3_stream *stream,
1094 const xd3_sec_type *sec, 1111 const xd3_sec_type *sec,
@@ -1213,7 +1230,8 @@ test_secondary (xd3_stream *stream, const xd3_sec_type *sec, int groups)
1213 1230
1214 CHECK(p_off == input_size); 1231 CHECK(p_off == input_size);
1215 1232
1216 if ((ret = test_secondary_decode (stream, sec, input_size, compress_size, dec_input, dec_correct, dec_output))) 1233 if ((ret = test_secondary_decode (stream, sec, input_size, compress_size,
1234 dec_input, dec_correct, dec_output)))
1217 { 1235 {
1218 DP(RINT "test %u: decode: %s", test_i, stream->msg); 1236 DP(RINT "test %u: decode: %s", test_i, stream->msg);
1219 goto fail; 1237 goto fail;
@@ -1229,9 +1247,12 @@ test_secondary (xd3_stream *stream, const xd3_sec_type *sec, int groups)
1229 { 1247 {
1230 dec_input[i/8] ^= 1 << (i%8); 1248 dec_input[i/8] ^= 1 << (i%8);
1231 1249
1232 if ((ret = test_secondary_decode (stream, sec, input_size, compress_size, dec_input, dec_correct, dec_output)) == 0) 1250 if ((ret = test_secondary_decode (stream, sec, input_size,
1251 compress_size, dec_input,
1252 dec_correct, dec_output)) == 0)
1233 { 1253 {
1234 /*DP(RINT "test %u: decode single-bit [%u/%u] error non-failure", test_i, i/8, i%8);*/ 1254 /*DP(RINT "test %u: decode single-bit [%u/%u]
1255 error non-failure", test_i, i/8, i%8);*/
1235 } 1256 }
1236 1257
1237 dec_input[i/8] ^= 1 << (i%8); 1258 dec_input[i/8] ^= 1 << (i%8);
@@ -1261,8 +1282,10 @@ test_secondary (xd3_stream *stream, const xd3_sec_type *sec, int groups)
1261 return 0; 1282 return 0;
1262} 1283}
1263 1284
1264IF_FGK (static int test_secondary_fgk (xd3_stream *stream, int gp) { return test_secondary (stream, & fgk_sec_type, gp); }) 1285IF_FGK (static int test_secondary_fgk (xd3_stream *stream, int gp)
1265IF_DJW (static int test_secondary_huff (xd3_stream *stream, int gp) { return test_secondary (stream, & djw_sec_type, gp); }) 1286 { return test_secondary (stream, & fgk_sec_type, gp); })
1287IF_DJW (static int test_secondary_huff (xd3_stream *stream, int gp)
1288 { return test_secondary (stream, & djw_sec_type, gp); })
1266#endif 1289#endif
1267 1290
1268/****************************************************************************************** 1291/******************************************************************************************