Lines Matching refs:TEST
57 COMMENT("Test pb_write and pb_ostream_t");
58 TEST(pb_write(&stream, buffer1, sizeof(buffer1)));
59 TEST(memcmp(buffer1, buffer2, sizeof(buffer1)) == 0);
60 TEST(!pb_write(&stream, buffer1, 1));
61 TEST(stream.bytes_written == sizeof(buffer1));
68 COMMENT("Test pb_write with custom callback");
69 TEST(pb_write(&stream, buffer1, 5));
71 TEST(!pb_write(&stream, buffer1, 5));
78 COMMENT("Test pb_encode_varint")
79 TEST(WRITES(pb_encode_varint(&s, 0), "\0"));
80 TEST(WRITES(pb_encode_varint(&s, 1), "\1"));
81 TEST(WRITES(pb_encode_varint(&s, 0x7F), "\x7F"));
82 TEST(WRITES(pb_encode_varint(&s, 0x80), "\x80\x01"));
83 TEST(WRITES(pb_encode_varint(&s, UINT32_MAX), "\xFF\xFF\xFF\xFF\x0F"));
84 TEST(WRITES(pb_encode_varint(&s, UINT64_MAX), "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x01"));
91 COMMENT("Test pb_encode_tag")
92 TEST(WRITES(pb_encode_tag(&s, PB_WT_STRING, 5), "\x2A"));
93 TEST(WRITES(pb_encode_tag(&s, PB_WT_VARINT, 99), "\x98\x06"));
101 COMMENT("Test pb_encode_tag_for_field")
102 TEST(WRITES(pb_encode_tag_for_field(&s, &field), "\x50"));
105 TEST(WRITES(pb_encode_tag_for_field(&s, &field), "\x51"));
108 TEST(WRITES(pb_encode_tag_for_field(&s, &field), "\x52"));
111 TEST(WRITES(pb_encode_tag_for_field(&s, &field), "\x55"));
118 COMMENT("Test pb_encode_string")
119 TEST(WRITES(pb_encode_string(&s, (const uint8_t*)"abcd", 4), "\x04""abcd"));
120 TEST(WRITES(pb_encode_string(&s, (const uint8_t*)"abcd\x00", 5), "\x05""abcd\x00"));
121 TEST(WRITES(pb_encode_string(&s, (const uint8_t*)"", 0), "\x00"));
134 COMMENT("Test pb_enc_varint and pb_enc_svarint")
135 TEST(WRITES(pb_enc_varint(&s, &field, &value), "\x01"));
138 TEST(WRITES(pb_enc_svarint(&s, &field, &max), "\xfe\xff\xff\xff\x0f"));
139 TEST(WRITES(pb_enc_svarint(&s, &field, &min), "\xff\xff\xff\xff\x0f"));
142 TEST(WRITES(pb_enc_svarint(&s, &field, &lmax), "\xFE\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x01"));
143 TEST(WRITES(pb_enc_svarint(&s, &field, &lmin), "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x01"));
152 COMMENT("Test pb_enc_fixed32 using float")
154 TEST(WRITES(pb_enc_fixed32(&s, NULL, &fvalue), "\x00\x00\x00\x00"))
156 TEST(WRITES(pb_enc_fixed32(&s, NULL, &fvalue), "\x00\x00\xc6\x42"))
158 TEST(WRITES(pb_enc_fixed32(&s, NULL, &fvalue), "\x4e\x61\x3c\xcb"))
160 COMMENT("Test pb_enc_fixed64 using double")
162 TEST(WRITES(pb_enc_fixed64(&s, NULL, &dvalue), "\x00\x00\x00\x00\x00\x00\x00\x00"))
164 TEST(WRITES(pb_enc_fixed64(&s, NULL, &dvalue), "\x00\x00\x00\x00\x00\xc0\x58\x40"))
166 TEST(WRITES(pb_enc_fixed64(&s, NULL, &dvalue), "\x00\x00\x00\xc0\x29\x8c\x67\xc1"))
174 COMMENT("Test pb_enc_bytes")
175 TEST(WRITES(pb_enc_bytes(&s, &BytesMessage_fields[0], &value), "\x05xyzzy"))
177 TEST(WRITES(pb_enc_bytes(&s, &BytesMessage_fields[0], &value), "\x00"))
185 COMMENT("Test pb_enc_string")
186 TEST(WRITES(pb_enc_string(&s, &StringMessage_fields[0], &value), "\x05xyzzy"))
188 TEST(WRITES(pb_enc_string(&s, &StringMessage_fields[0], &value), "\x00"))
190 TEST(WRITES(pb_enc_string(&s, &StringMessage_fields[0], &value), "\x0Axxxxxxxxxx"))
198 COMMENT("Test pb_encode with int32 array")
200 TEST(WRITES(pb_encode(&s, IntegerArray_fields, &msg), "\x0A\x05\x01\x02\x03\x04\x05"))
203 TEST(WRITES(pb_encode(&s, IntegerArray_fields, &msg), ""))
206 TEST(!pb_encode(&s, IntegerArray_fields, &msg))
214 COMMENT("Test pb_encode with float array")
216 TEST(WRITES(pb_encode(&s, FloatArray_fields, &msg),
220 TEST(WRITES(pb_encode(&s, FloatArray_fields, &msg), ""))
223 TEST(!pb_encode(&s, FloatArray_fields, &msg))
231 COMMENT("Test array size limit in pb_encode")
234 TEST((msg.data_count = 10) && pb_encode(&s, FloatArray_fields, &msg))
237 TEST((msg.data_count = 11) && !pb_encode(&s, FloatArray_fields, &msg))
247 COMMENT("Test pb_encode with callback field.")
248 TEST(WRITES(pb_encode(&s, CallbackArray_fields, &msg), "\x08\x55"))
256 COMMENT("Test pb_encode with packed array in a submessage.")
257 TEST(WRITES(pb_encode(&s, IntegerContainer_fields, &msg),
266 COMMENT("Test pb_encode with bytes message.")
267 TEST(WRITES(pb_encode(&s, BytesMessage_fields, &msg),
271 TEST(!pb_encode(&s, BytesMessage_fields, &msg))
280 COMMENT("Test pb_encode_delimited.")
281 TEST(WRITES(pb_encode_delimited(&s, IntegerContainer_fields, &msg),
289 COMMENT("Test pb_get_encoded_size.")
290 TEST(pb_get_encoded_size(&size, IntegerContainer_fields, &msg) &&
304 COMMENT("Test pb_encode with callback field in a submessage.")
305 TEST(WRITES(pb_encode(&s, CallbackContainer_fields, &msg), "\x0A\x02\x08\x55"))
306 TEST(WRITES(pb_encode(&s, CallbackContainerContainer_fields, &msg2),
315 TEST(!pb_encode(&s, CallbackContainer_fields, &msg))
317 TEST(!pb_encode(&s, CallbackContainerContainer_fields, &msg2))
327 COMMENT("Test that StringMessage_size is correct")
329 TEST(pb_encode(&s, StringMessage_fields, &msg));
330 TEST(s.bytes_written == StringMessage_size);