des bubulles
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

tbb.c 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /*
  2. * this is rudimentary test for the bubulles manager
  3. *
  4. * contact: <tth> on IRC freenode#tetalab
  5. */
  6. #include <stdio.h>
  7. #include <stdlib.h>
  8. #include "bubulles.h"
  9. /* --------------------------------------------------------------------- */
  10. void test_alloc_free(int nbelm)
  11. {
  12. BBList *bublist;
  13. int foo;
  14. bublist = alloc_bubulles("plop !", nbelm, 0);
  15. if (NULL==bublist) {
  16. fprintf(stderr, "err in %s, aborting...\n", __func__);
  17. abort();
  18. }
  19. print_bublist_desc(bublist, 1);
  20. foo = free_bubulles(bublist, 0);
  21. printf("free bubulles -> %d\n", foo);
  22. }
  23. /* --------------------------------------------------------------------- */
  24. int test_push_pop(int nbelm)
  25. {
  26. BBList *bublist;
  27. int foo, idx;
  28. Bubulle bubulle;
  29. bublist = alloc_bubulles("push & pop", nbelm, 0);
  30. for (idx=0; idx<nbelm; idx++) {
  31. bubulle.p.x = (double)idx;
  32. bubulle.p.y = bubulle.p.z = 0.3;
  33. foo = push_bubulle(bublist, &bubulle);
  34. }
  35. /* WTF ? where is the 'pop' test ? */
  36. foo = bubulles_to_data("dummy-file", NULL, bublist, 0);
  37. printf("ecriture bubulles -> %d\n", foo);
  38. foo = free_bubulles(bublist, 0);
  39. printf("free bubulles -> %d\n", foo);
  40. return 0;
  41. }
  42. /* --------------------------------------------------------------------- */
  43. int test_cleanfill_my_bublist(int krkrkr)
  44. {
  45. BBList *bublist;
  46. int foo;
  47. bublist = alloc_bubulles("cleanfill", 567890, 0);
  48. foo = cleanfill_my_bublist(bublist, 0);
  49. fprintf(stderr, "clean & fill -> %d\n", foo);
  50. free_bubulles(bublist, 0);
  51. return 0;
  52. }
  53. /* --------------------------------------------------------------------- */
  54. int test_peek_poke(int nbre)
  55. {
  56. BBList *bublist;
  57. int foo, in, out;
  58. Bubulle bubulle;
  59. bublist = alloc_bubulles("peek & poke", nbre, 0);
  60. print_bublist_desc(bublist, 0);
  61. in = nbre / 2;
  62. out = nbre + 42;
  63. foo = peek_bubulle(bublist, &bubulle, in);
  64. printf("peek 1 -> %7d\n", foo);
  65. foo = niceprint_bubulle(&bubulle, 0);
  66. printf("niceprint -> %7d\n", foo);
  67. foo = peek_bubulle(bublist, &bubulle, out);
  68. printf("peek 2 -> %7d\n", foo);
  69. bubulle.p.y = 3.14159;
  70. foo = poke_bubulle(bublist, &bubulle, in);
  71. printf("poke 1 -> %7d\n", foo);
  72. foo = peek_bubulle(bublist, &bubulle, in);
  73. printf("peek 3 -> %7d\n", foo);
  74. foo = niceprint_bubulle(&bubulle, 0);
  75. printf("niceprint -> %7d\n", foo);
  76. free_bubulles(bublist, 0);
  77. return 0;
  78. }
  79. /* --------------------------------------------------------------------- */
  80. int main(int argc, char *argv[])
  81. {
  82. int foo;
  83. printf("*** Bubulles Testing -- %s %s\n\n", __DATE__, __TIME__);
  84. bubulles_version(1);
  85. test_alloc_free(5);
  86. test_push_pop(20000);
  87. test_cleanfill_my_bublist(999);
  88. foo = test_peek_poke(5000);
  89. fprintf(stderr, "test peek/poke -> %d\n", foo);
  90. return 0;
  91. }