17 static const size_t size = 8;
19 static const uint8_t decoded[
size] = {0x86, 0x4F, 0xD2, 0x6F,
20 0xB5, 0x59, 0xF7, 0x5B};
21 static const char expected[
length + 1] =
"HelloWorld";
22 char out_encoded[
length + 1] = {0};
41 static const size_t size = 10 * 4 / 5;
42 static const uint8_t expected[
size] = {0x86, 0x4F, 0xD2, 0x6F,
43 0xB5, 0x59, 0xF7, 0x5B};
44 static const char *encoded =
"HelloWorld";
45 uint8_t out_decoded[
size] = {0};
54 template <
size_t SIZE>
57 uint8_t decoded[SIZE * 4 / 5 + 1];
65 template <
size_t SIZE>
67 const uint8_t (&test_data_)[SIZE])
69 char test_data_z85[SIZE * 5 / 4 + 1];
70 const char *
const res1 =
zmq_z85_encode (test_data_z85, test_data_, SIZE);
73 uint8_t test_data_decoded[SIZE];
74 const uint8_t *
const res2 =
82 template <
size_t SIZE>
84 const char (&test_data_)[SIZE])
86 const size_t decoded_size = (SIZE - 1) * 4 / 5;
87 uint8_t test_data_decoded[decoded_size];
88 const uint8_t *
const res1 =
zmq_z85_decode (test_data_decoded, test_data_);
91 char test_data_z85[SIZE];
92 const char *
const res2 =
99 #define def_test__zmq_z85_basename(basename, name, param) \
100 void test__zmq_z85_##basename##_##name () \
102 test__zmq_z85_##basename (param); \
105 #define def_test__zmq_z85_encode__invalid__failure(name, param) \
106 def_test__zmq_z85_basename (encode__invalid__failure, name, param)
111 #define def_test__zmq_z85_decode__invalid__failure(name, param) \
112 def_test__zmq_z85_basename (decode__invalid__failure, name, param)
138 #define def_test__encode__zmq_z85_decode__roundtrip(name, param) \
139 def_test__zmq_z85_basename (encode__zmq_z85_decode__roundtrip, name, param)
141 const uint8_t test_data_min[] = {0x00, 0x00, 0x00, 0x00};
147 #define def_test__decode__zmq_z85_encode__roundtrip(name, param) \
148 def_test__zmq_z85_basename (decode__zmq_z85_encode__roundtrip, name, param)
158 RUN_TEST (test__zmq_z85_encode__invalid__failure_1);
159 RUN_TEST (test__zmq_z85_encode__invalid__failure_42);
163 test__zmq_z85_decode__invalid__failure_indivisble_by_5_multiple_chars);
164 RUN_TEST (test__zmq_z85_decode__invalid__failure_indivisble_by_5_one_char);
165 RUN_TEST (test__zmq_z85_decode__invalid__failure_max);
166 RUN_TEST (test__zmq_z85_decode__invalid__failure_above_limit);
167 RUN_TEST (test__zmq_z85_decode__invalid__failure_char_within);
168 RUN_TEST (test__zmq_z85_decode__invalid__failure_char_adjacent_below);
169 RUN_TEST (test__zmq_z85_decode__invalid__failure_char_adjacent_above);
171 RUN_TEST (test__zmq_z85_encode__zmq_z85_decode__roundtrip_min);
172 RUN_TEST (test__zmq_z85_encode__zmq_z85_decode__roundtrip_max);
174 RUN_TEST (test__zmq_z85_decode__zmq_z85_encode__roundtrip_regular);