1 #include "../../test.h"
2 #include "../../../src/server/protocol1/blocklen.h"
3
4 struct end_data
5 {
6 const char *endfile;
7 size_t ret_expected;
8 };
9
10 static struct end_data in[] = {
11 { "0", 64 },
12 { "1024", 64 },
13 { "2048", 64 },
14 { "4096", 64 },
15 { "8192", 96 },
16 { "16384", 128 },
17 { "32768", 192 },
18 { "65536", 256 },
19 { "131072", 368 },
20 { "55555555", 7456 },
21 { "555555555", 23584 },
22 { "5555555555", 74544 },
23 { "55555555555", 131072 },
24 { "555555555555", 131072 },
25 };
26
START_TEST(test_get_librsync_block_len)27 START_TEST(test_get_librsync_block_len)
28 {
29 FOREACH(in)
30 {
31 size_t result=get_librsync_block_len(in[i].endfile);
32 fail_unless(result==in[i].ret_expected);
33 }
34 alloc_check();
35 }
36 END_TEST
37
suite_server_protocol1_blocklen(void)38 Suite *suite_server_protocol1_blocklen(void)
39 {
40 Suite *s;
41 TCase *tc_core;
42
43 s=suite_create("server_protocol1_blocklen");
44
45 tc_core=tcase_create("Core");
46
47 tcase_add_test(tc_core, test_get_librsync_block_len);
48 suite_add_tcase(s, tc_core);
49
50 return s;
51 }
52