134 lines
2.9 KiB
C
134 lines
2.9 KiB
C
/*
|
|
* this is rudimentary test for the bubulles manages
|
|
*
|
|
* contact: <tth> on IRC freenode#tetalab
|
|
*/
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
#include "bubulles.h"
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
void print_sizeof(void)
|
|
{
|
|
printf("%-15s %4lu\n", "XYZ", sizeof(XYZ));
|
|
printf("%-15s %4lu\n", "RGBA", sizeof(RGBA));
|
|
printf("%-15s %4lu\n", "Bubulle", sizeof(Bubulle));
|
|
printf("%-15s %4lu\n", "BBList", sizeof(BBList));
|
|
puts("");
|
|
}
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
void test_alloc_free(int nbelm)
|
|
{
|
|
BBList *bublist;
|
|
int foo;
|
|
|
|
bublist = alloc_bubulles("plop !", nbelm, 0);
|
|
if (NULL==bublist) {
|
|
fprintf(stderr, "err in %s, aborting...\n", __func__);
|
|
abort();
|
|
}
|
|
print_bublist_desc(bublist, 1);
|
|
|
|
foo = free_bubulles(bublist, 0);
|
|
printf("free bubulles -> %d\n", foo);
|
|
|
|
}
|
|
/* --------------------------------------------------------------------- */
|
|
int test_push_pop(int nbelm)
|
|
{
|
|
BBList *bublist;
|
|
int foo, idx;
|
|
Bubulle bubulle;
|
|
|
|
bublist = alloc_bubulles("push & pop", nbelm, 0);
|
|
|
|
for (idx=0; idx<nbelm; idx++) {
|
|
bubulle.p.x = (double)idx;
|
|
bubulle.p.y = bubulle.p.z = 0.3;
|
|
foo = push_bubulle(bublist, &bubulle);
|
|
}
|
|
|
|
/* WTF ? where is the 'pop' test ? */
|
|
|
|
foo = bubulles_to_data("dummy-file", NULL, bublist, 0);
|
|
printf("ecriture bubulles -> %d\n", foo);
|
|
|
|
foo = free_bubulles(bublist, 0);
|
|
printf("free bubulles -> %d\n", foo);
|
|
|
|
return 0;
|
|
}
|
|
/* --------------------------------------------------------------------- */
|
|
int test_cleanfill_my_bublist(int krkrkr)
|
|
{
|
|
BBList *bublist;
|
|
int foo;
|
|
|
|
bublist = alloc_bubulles("cleanfill", 567890, 0);
|
|
foo = cleanfill_my_bublist(bublist, 0);
|
|
fprintf(stderr, "clean & fill -> %d\n", foo);
|
|
free_bubulles(bublist, 0);
|
|
|
|
return 0;
|
|
}
|
|
/* --------------------------------------------------------------------- */
|
|
int test_peek_poke(int nbre)
|
|
{
|
|
BBList *bublist;
|
|
int foo, in, out;
|
|
Bubulle bubulle;
|
|
|
|
bublist = alloc_bubulles("peek & poke", nbre, 0);
|
|
print_bublist_desc(bublist, 0);
|
|
|
|
in = nbre / 2;
|
|
out = nbre + 42;
|
|
|
|
foo = peek_bubulle(bublist, &bubulle, in);
|
|
printf("peek 1 -> %7d\n", foo);
|
|
|
|
foo = niceprint_bubulle(&bubulle, 0);
|
|
printf("niceprint -> %7d\n", foo);
|
|
|
|
foo = peek_bubulle(bublist, &bubulle, out);
|
|
printf("peek 2 -> %7d\n", foo);
|
|
|
|
bubulle.p.y = 3.14159;
|
|
foo = poke_bubulle(bublist, &bubulle, in);
|
|
printf("poke 1 -> %7d\n", foo);
|
|
|
|
foo = peek_bubulle(bublist, &bubulle, in);
|
|
printf("peek 3 -> %7d\n", foo);
|
|
|
|
foo = niceprint_bubulle(&bubulle, 0);
|
|
printf("niceprint -> %7d\n", foo);
|
|
|
|
free_bubulles(bublist, 0);
|
|
|
|
return 0;
|
|
}
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
int main(int argc, char *argv[])
|
|
{
|
|
int foo;
|
|
|
|
printf("*** Bubulles Testing -- %s %s\n\n", __DATE__, __TIME__);
|
|
|
|
bubulles_version(1);
|
|
|
|
test_alloc_free(5);
|
|
test_push_pop(2000);
|
|
test_cleanfill_my_bublist(999);
|
|
|
|
/*
|
|
foo = test_peek_poke(5000);
|
|
fprintf(stderr, "test peek/poke -> %d\n", foo);
|
|
*/
|
|
|
|
return 0;
|
|
}
|