librlp

C library for the Recursive Length Prefix (RLP) serialization format
git clone git://git.defalsify.org/librlp.git
Info | Log | Files | Refs | README | LICENSE

check_rlp.c (868B)


      1 #include <check.h>
      2 
      3 #include "rlp.h"
      4 
      5 
      6 START_TEST(rlp_init_alloc_test) {
      7 	rlp_encoder_t encoder;
      8 
      9 	rlp_init(&encoder, 1024, NULL);
     10 
     11 	ck_assert_int_eq(encoder.state, RLP_ENCODE);
     12 
     13 	rlp_free(&encoder);
     14 }
     15 END_TEST
     16 
     17 
     18 START_TEST(rlp_init_noalloc_test) {
     19 	char something[] = "foo";
     20 
     21 	rlp_encoder_t encoder;
     22 
     23 	rlp_init(&encoder, 4, something);
     24 
     25 	ck_assert_int_eq(encoder.state, RLP_DECODE);
     26 
     27 	rlp_free(&encoder);
     28 }
     29 END_TEST
     30 
     31 Suite *rlp_init_suite(void) {
     32 	Suite *s;
     33 	TCase *tc;
     34 
     35 	s = suite_create("rlp");
     36 	tc = tcase_create("init");
     37 
     38 	tcase_add_test(tc, rlp_init_alloc_test);
     39 	suite_add_tcase(s, tc);
     40 
     41 	return s;
     42 }
     43 
     44 
     45 int main(void) {
     46 	int num_fail;
     47 
     48 	Suite *s;
     49 	SRunner *sr;
     50 
     51 	s = rlp_init_suite();
     52 	sr = srunner_create(s);
     53 
     54 	srunner_run_all(sr, CK_VERBOSE);
     55 	num_fail = srunner_ntests_failed(sr);
     56 	srunner_free(sr);
     57 
     58 	return (num_fail == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
     59 }