Revision ec807410 som/Tests/cb_test.c

View differences:

som/Tests/cb_test.c
28 28
static void chunk_add(struct chunk_buffer *cb, int id)
29 29
{
30 30
  struct chunk *c;
31
  int res;
31 32

  
32
  printf("Inserting %d\n", id);
33
  printf("Inserting %d... ", id);
33 34
  c = chunk_forge(id);
34 35
  if (c) {
35
    cb_add_chunk(cb, c);
36
    res = cb_add_chunk(cb, c);
37
    if (res < 0) {
38
      printf("not inserted (out of window)");
39
    }
36 40
  } else {
37 41
    printf("Failed to create the chunk");
38 42
  }
43
  printf("\n");
39 44
  free(c);
40 45
}
41 46

  
......
54 59
{
55 60
  struct chunk_buffer *b;
56 61

  
57
  b = cb_init("size=32");
62
  b = cb_init("size=8,time=now");
58 63
  if (b == NULL) {
59 64
    printf("Error initialising the Chunk Buffer\n");
60 65

  
......
64 69
  chunk_add(b, 5);
65 70
  chunk_add(b, 12);
66 71
  chunk_add(b, 40);
72
  cb_print(b);
73

  
67 74
  chunk_add(b, 51);
68 75
  chunk_add(b, 2);
69 76
  chunk_add(b, 13);
70 77
  chunk_add(b, 11);
78
  cb_print(b);
79

  
71 80
  chunk_add(b, 26);
81
  cb_print(b);
72 82
  chunk_add(b, 30);
73 83
  cb_print(b);
84
  chunk_add(b, 110);
85
  cb_print(b);
86
  chunk_add(b, 64);
87
  chunk_add(b, 4);
88
  cb_print(b);
89
  chunk_add(b, 7);
90
  chunk_add(b, 34);
91
  chunk_add(b, 2);
92
  chunk_add(b, 33);
93
  cb_print(b);
74 94

  
75 95
  cb_destroy(b);
76 96

  

Also available in: Unified diff