tests: add tests for secp256k1_{read,write}_be64
This can be reviewed with `--ignore-all-space` (or `-w`), to ignore already existing code that was only indented.
This commit is contained in:
parent
740528caad
commit
7067ee54b4
15
src/tests.c
15
src/tests.c
@ -7516,6 +7516,7 @@ static void run_secp256k1_memczero_test(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void run_secp256k1_byteorder_tests(void) {
|
static void run_secp256k1_byteorder_tests(void) {
|
||||||
|
{
|
||||||
const uint32_t x = 0xFF03AB45;
|
const uint32_t x = 0xFF03AB45;
|
||||||
const unsigned char x_be[4] = {0xFF, 0x03, 0xAB, 0x45};
|
const unsigned char x_be[4] = {0xFF, 0x03, 0xAB, 0x45};
|
||||||
unsigned char buf[4];
|
unsigned char buf[4];
|
||||||
@ -7528,6 +7529,20 @@ static void run_secp256k1_byteorder_tests(void) {
|
|||||||
CHECK(x == x_);
|
CHECK(x == x_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
const uint64_t x = 0xCAFE0123BEEF4567;
|
||||||
|
const unsigned char x_be[8] = {0xCA, 0xFE, 0x01, 0x23, 0xBE, 0xEF, 0x45, 0x67};
|
||||||
|
unsigned char buf[8];
|
||||||
|
uint64_t x_;
|
||||||
|
|
||||||
|
secp256k1_write_be64(buf, x);
|
||||||
|
CHECK(secp256k1_memcmp_var(buf, x_be, sizeof(buf)) == 0);
|
||||||
|
|
||||||
|
x_ = secp256k1_read_be64(buf);
|
||||||
|
CHECK(x == x_);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void int_cmov_test(void) {
|
static void int_cmov_test(void) {
|
||||||
int r = INT_MAX;
|
int r = INT_MAX;
|
||||||
int a = 0;
|
int a = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user