File: cache8_test.c

package info (click to toggle)
ruby-ox 2.14.23-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,504 kB
  • sloc: xml: 39,683; ansic: 9,626; ruby: 6,441; sh: 47; makefile: 2
file content (44 lines) | stat: -rw-r--r-- 1,271 bytes parent folder | download | duplicates (2)
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
37
38
39
40
41
42
43
44
/* cache8_test.c
 * Copyright (c) 2011, Peter Ohler
 * All rights reserved.
 */

#include "cache8.h"

#include <stdio.h>

static slot_t data[] = {0x000000A0A0A0A0A0ULL,
                        0x0000000000ABCDEFULL,
                        0x0123456789ABCDEFULL,
                        0x0000000000000001ULL,
                        0x0000000000000002ULL,
                        0x0000000000000003ULL,
                        0x0000000000000004ULL,
                        0};

void ox_cache8_test() {
    Cache8  c;
    slot_t  v;
    slot_t *d;
    slot_t  cnt  = 1;
    slot_t *slot = 0;

    ox_cache8_new(&c);
    for (d = data; 0 != *d; d++) {
        v = ox_cache8_get(c, *d, &slot);
        if (0 == v) {
            if (0 == slot) {
                printf("*** failed to get a slot for 0x%016llx\n", (unsigned long long)*d);
            } else {
                printf("*** adding 0x%016llx to cache with value %llu\n",
                       (unsigned long long)*d,
                       (unsigned long long)cnt);
                *slot = cnt++;
            }
        } else {
            printf("*** get on 0x%016llx returned %llu\n", (unsigned long long)*d, (unsigned long long)v);
        }
        /*ox_cache8_print(c); */
    }
    ox_cache8_print(c);
}