Statistics
| Branch: | Revision:

grapes / src / Tests / chunkidset_test_bug.c @ 7b60aa43

History | View | Annotate | Download (1.19 KB)

1 b3dd32b0 Alessandro Russo
/*
2
 *  Copyright (c) 2009 Luca Abeni
3
 *
4
 *  This is free software; see gpl-3.0.txt
5
 */
6
7 438e6c03 Luca Abeni
#include <inttypes.h>
8 b3dd32b0 Alessandro Russo
#include <stdint.h>
9
#include <stdlib.h>
10
#include <stdio.h>
11
#include <string.h>
12 438e6c03 Luca Abeni
13 b3dd32b0 Alessandro Russo
#include "chunkidset.h"
14 438e6c03 Luca Abeni
15 b3dd32b0 Alessandro Russo
#include "chunkid_set_h.h"
16
17 6d1a7eaa Luca Abeni
static void display_cset(struct chunkID_set *cset)
18
{
19 01769d8a Alessandro Russo
  uint32_t ret;
20
21 6d1a7eaa Luca Abeni
  printf("Chunk ID Set initialised: size is %d\n", chunkID_set_size(cset));
22
  printChunkID_set(cset);
23 01769d8a Alessandro Russo
  printf("Earliest chunk %"PRIu32"\n", (ret = chunkID_set_get_earliest(cset)));
24
  printf("%s chunk\n",(ret == CHUNKID_INVALID ? "Invalid" : "Valid"));
25 6d1a7eaa Luca Abeni
  check_chunk(cset, 0);
26 01769d8a Alessandro Russo
  printf("Latest chunk %"PRIu32"\n", (ret = chunkID_set_get_latest(cset)));
27
  printf("%s chunk\n",(ret == CHUNKID_INVALID ? "Invalid" : "Valid"));
28 6d1a7eaa Luca Abeni
  check_chunk(cset, 0);
29
}
30
31 b3dd32b0 Alessandro Russo
static void simple_test(void)
32
{
33
  struct chunkID_set *cset;
34
  char config[32];
35
36
  sprintf(config, "size=%d", 10);
37
  cset = chunkID_set_init(config);
38
  if(!cset) {
39
    fprintf(stderr, "Unable to allocate memory for rcset\n");
40
41
    return;
42
  }
43
44 6d1a7eaa Luca Abeni
  display_cset(cset);
45
  chunkID_set_add_chunk(cset, 7);
46
  chunkID_set_add_chunk(cset, 2);
47
  display_cset(cset);
48
49 b3dd32b0 Alessandro Russo
  chunkID_set_free(cset);
50
}
51
52
int main(int argc, char *argv[])
53
{
54
  simple_test();
55
56
  return 0;
57
}