Statistics
| Branch: | Revision:

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

History | View | Annotate | Download (1.19 KB)

1
/*
2
 *  Copyright (c) 2009 Luca Abeni
3
 *
4
 *  This is free software; see gpl-3.0.txt
5
 */
6

    
7
#include <inttypes.h>
8
#include <stdint.h>
9
#include <stdlib.h>
10
#include <stdio.h>
11
#include <string.h>
12

    
13
#include "chunkidset.h"
14

    
15
#include "chunkid_set_h.h"
16

    
17
static void display_cset(struct chunkID_set *cset)
18
{
19
  uint32_t ret;
20

    
21
  printf("Chunk ID Set initialised: size is %d\n", chunkID_set_size(cset));
22
  printChunkID_set(cset);
23
  printf("Earliest chunk %"PRIu32"\n", (ret = chunkID_set_get_earliest(cset)));
24
  printf("%s chunk\n",(ret == CHUNKID_INVALID ? "Invalid" : "Valid"));
25
  check_chunk(cset, 0);
26
  printf("Latest chunk %"PRIu32"\n", (ret = chunkID_set_get_latest(cset)));
27
  printf("%s chunk\n",(ret == CHUNKID_INVALID ? "Invalid" : "Valid"));
28
  check_chunk(cset, 0);
29
}
30

    
31
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
  display_cset(cset);
45
  chunkID_set_add_chunk(cset, 7);
46
  chunkID_set_add_chunk(cset, 2);
47
  display_cset(cset);
48

    
49
  chunkID_set_free(cset);
50
}
51

    
52
int main(int argc, char *argv[])
53
{
54
  simple_test();
55

    
56
  return 0;
57
}