File: test_bitarr.c

package info (click to toggle)
sphinxbase 0.8%2B5prealpha-3
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 10,592 kB
  • ctags: 3,296
  • sloc: ansic: 29,950; sh: 11,802; makefile: 679; python: 335; perl: 121; yacc: 93; lex: 50
file content (36 lines) | stat: -rw-r--r-- 862 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/**
 * @file test_bitarr.c Test bit array io
 */

#include "bitarr.h"
#include "test_macros.h"

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef union {
    float f;
    uint32 i;
} float_enc;

int
main(int argc, char *argv[])
{
    float_enc neg1 = { -1.0 }, pos1 = { 1.0 };
    uint64 test57 = 0x123456789abcdefULL;
    char mem[57+8];
    bitarr_address_t address;
    //sign bit should be 0x80000000
    TEST_EQUAL((neg1.i ^ pos1.i), 0x80000000);
    memset(mem, 0, sizeof(mem));
    address.base = mem;
    for (address.offset = 0; address.offset < 57 * 8; address.offset += 57) {
      bitarr_write_int57(address, 57, test57);
    }
    for (address.offset = 0; address.offset < 57 * 8; address.offset += 57) {
      TEST_EQUAL(test57, bitarr_read_int57(address, 57, ((1ULL << 57) - 1)));
    }
    // TODO: more checks.
    return 0;
}