MCPcopy Create free account
hub / github.com/ElementsProject/elements / test_decodeUptoMaxInt

Function test_decodeUptoMaxInt

src/simplicity/test.c:50–72  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

48}
49
50static void test_decodeUptoMaxInt(void) {
51 printf("Test decodeUptoMaxInt\n");
52 const unsigned char buf[] =
53 { 0x4b, 0x86, 0x39, 0xe8, 0xdf, 0xc0, 0x38, 0x0f, 0x7f, 0xff, 0xff, 0x00
54 , 0x00, 0x00, 0xf0, 0xe0, 0x00, 0x00, 0x00, 0x3c, 0x3b, 0xff, 0xff, 0xff
55 , 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00
56 };
57 const int32_t expected[] =
58 { 1, 2, 3, 4, 5, 7, 8, 15, 16, 17
59 , 0xffff, 0x10000, 0x40000000, 0x7fffffff, SIMPLICITY_ERR_DATA_OUT_OF_RANGE
60 };
61
62 bitstream stream = initializeBitstream(buf, sizeof(buf));
63 for (size_t i = 0; i < sizeof(expected)/sizeof(expected[0]); ++i) {
64 int32_t result = simplicity_decodeUptoMaxInt(&stream);
65 if (expected[i] == result) {
66 successes++;
67 } else {
68 failures++;
69 printf("Unexpected result during parsing. Expected %d and received %d\n", expected[i], result);
70 }
71 }
72}
73
74static void test_hashBlock(void) {
75 printf("Test hashBlock\n");

Callers 1

mainFunction · 0.85

Calls 3

printfFunction · 0.85
initializeBitstreamFunction · 0.85

Tested by

no test coverage detected