void func(void); /*prototype*/ \
void func(void)
-#if 1 || defined(XBT_USE_DEPRECATED)
+#ifdef XBT_USE_DEPRECATED
/* Kept for backward compatibility. */
XBT_TEST_UNIT("memuse", test_config_memuse, "Alloc and free a config set")
{
xbt_cfg_t set = make_set();
- xbt_test_add0("Alloc and free a config set");
+ xbt_test_add("Alloc and free a config set");
xbt_cfg_set_parse(set,
"peername:veloce user:mquinson\nuser:oaumage\tuser:alegrand");
xbt_cfg_free(&set);
xbt_cfg_t set = set = make_set();
xbt_ex_t e;
- xbt_test_add0("Having too few elements for speed");
+ xbt_test_add("Having too few elements for speed");
xbt_cfg_set_parse(set,
"peername:veloce user:mquinson\nuser:oaumage\tuser:alegrand");
TRY {
if (e.category != mismatch_error ||
strncmp(e.msg, "Config elem speed needs",
strlen("Config elem speed needs")))
- xbt_test_fail1("Got an exception. msg=%s", e.msg);
+ xbt_test_fail("Got an exception. msg=%s", e.msg);
xbt_ex_free(e);
}
xbt_cfg_free(&set);
- xbt_test_add0("Having too much values of 'speed'");
+ xbt_test_add("Having too much values of 'speed'");
set = make_set();
xbt_cfg_set_parse(set, "peername:toto:42 user:alegrand");
TRY {
if (e.category != mismatch_error ||
strncmp(e.msg, "Cannot add value 34 to the config elem speed",
strlen("Config elem speed needs")))
- xbt_test_fail1("Got an exception. msg=%s", e.msg);
+ xbt_test_fail("Got an exception. msg=%s", e.msg);
xbt_ex_free(e);
}
xbt_cfg_check(set);
XBT_TEST_UNIT("use", test_config_use, "Data retrieving tests")
{
- xbt_test_add0("Get a single value");
+ xbt_test_add("Get a single value");
{
/* get_single_value */
int ival;
xbt_cfg_set_parse(myset, "peername:toto:42 speed:42");
ival = xbt_cfg_get_int(myset, "speed");
if (ival != 42)
- xbt_test_fail1("Speed value = %d, I expected 42", ival);
+ xbt_test_fail("Speed value = %d, I expected 42", ival);
xbt_cfg_free(&myset);
}
- xbt_test_add0("Get multiple values");
+ xbt_test_add("Get multiple values");
{
/* get_multiple_value */
xbt_dynar_t dyn;
dyn = xbt_cfg_get_dynar(myset, "user");
if (xbt_dynar_length(dyn) != 3)
- xbt_test_fail1("Dynar length = %lu, I expected 3",
+ xbt_test_fail("Dynar length = %lu, I expected 3",
xbt_dynar_length(dyn));
if (strcmp(xbt_dynar_get_as(dyn, 0, char *), "foo"))
- xbt_test_fail1("Dynar[0] = %s, I expected foo",
+ xbt_test_fail("Dynar[0] = %s, I expected foo",
xbt_dynar_get_as(dyn, 0, char *));
if (strcmp(xbt_dynar_get_as(dyn, 1, char *), "bar"))
- xbt_test_fail1("Dynar[1] = %s, I expected bar",
+ xbt_test_fail("Dynar[1] = %s, I expected bar",
xbt_dynar_get_as(dyn, 1, char *));
if (strcmp(xbt_dynar_get_as(dyn, 2, char *), "toto"))
- xbt_test_fail1("Dynar[2] = %s, I expected toto",
+ xbt_test_fail("Dynar[2] = %s, I expected toto",
xbt_dynar_get_as(dyn, 2, char *));
xbt_cfg_free(&myset);
}
- xbt_test_add0("Access to a non-existant entry");
+ xbt_test_add("Access to a non-existant entry");
{
/* non-existant_entry */
xbt_cfg_t myset = make_set();
XBT_TEST_UNIT("expect", test_expected_failure, "expected failures")
{
- xbt_test_add0("Skipped test");
+ xbt_test_add("Skipped test");
xbt_test_skip();
- xbt_test_add2("%s %s", "EXPECTED", "FAILURE");
+ xbt_test_add("%s %s", "EXPECTED", "FAILURE");
xbt_test_expect_failure();
- xbt_test_log2("%s %s", "Test", "log");
- xbt_test_fail0("EXPECTED FAILURE");
+ xbt_test_log("%s %s", "Test", "log");
+ xbt_test_fail("EXPECTED FAILURE");
}
#endif /* SIMGRID_TEST */
{
char *data = xbt_strdup(data_to_fill);
- xbt_test_log2("Add %s under %s", PRINTF_STR(data_to_fill),
+ xbt_test_log("Add %s under %s", PRINTF_STR(data_to_fill),
PRINTF_STR(key));
xbt_dict_set(head, key, data, &free);
static void fill(xbt_dict_t * head)
{
- xbt_test_add0("Fill in the dictionnary");
+ xbt_test_add("Fill in the dictionnary");
*head = xbt_dict_new();
debuged_add(*head, "12");
{
void *found;
- xbt_test_add1("Search %s", key);
+ xbt_test_add("Search %s", key);
found = xbt_dict_get(head, key);
- xbt_test_log1("Found %s", (char *) found);
+ xbt_test_log("Found %s", (char *) found);
if (data)
- xbt_test_assert1(found,
+ xbt_test_assert(found,
"data do not match expectations: found NULL while searching for %s",
data);
if (found)
- xbt_test_assert2(!strcmp((char *) data, found),
+ xbt_test_assert(!strcmp((char *) data, found),
"data do not match expectations: found %s while searching for %s",
(char *) found, data);
}
static void debuged_remove(xbt_dict_t head, const char *key)
{
- xbt_test_add1("Remove '%s'", PRINTF_STR(key));
+ xbt_test_add("Remove '%s'", PRINTF_STR(key));
xbt_dict_remove(head, key);
/* xbt_dict_dump(head,(void (*)(void*))&printf); */
}
xbt_dict_foreach(head, cursor, key, data) {
if (!key || !data || strcmp(key, data)) {
- xbt_test_log3("Seen #%d: %s->%s", ++i, PRINTF_STR(key),
+ xbt_test_log("Seen #%d: %s->%s", ++i, PRINTF_STR(key),
PRINTF_STR(data));
} else {
- xbt_test_log2("Seen #%d: %s", ++i, PRINTF_STR(key));
+ xbt_test_log("Seen #%d: %s", ++i, PRINTF_STR(key));
}
- xbt_test_assert2(!data || !strcmp(key, data),
+ xbt_test_assert(!data || !strcmp(key, data),
"Key(%s) != value(%s). Aborting", key, data);
}
}
int ok = 0;
xbt_ex_t e;
- xbt_test_add1("Search %s (expected not to be found)", data);
+ xbt_test_add("Search %s (expected not to be found)", data);
TRY {
data = xbt_dict_get(head, data);
xbt_ex_free(e);
ok = 1;
}
- xbt_test_assert0(ok, "Exception not raised");
+ xbt_test_assert(ok, "Exception not raised");
}
static void count(xbt_dict_t dict, int length)
int effective = 0;
- xbt_test_add1("Count elements (expecting %d)", length);
- xbt_test_assert2(xbt_dict_length(dict) == length,
+ xbt_test_add("Count elements (expecting %d)", length);
+ xbt_test_assert(xbt_dict_length(dict) == length,
"Announced length(%d) != %d.", xbt_dict_length(dict),
length);
xbt_dict_foreach(dict, cursor, key, data)
effective++;
- xbt_test_assert2(effective == length, "Effective length(%d) != %d.",
+ xbt_test_assert(effective == length, "Effective length(%d) != %d.",
effective, length);
}
int effective = 0;
- xbt_test_add1
+ xbt_test_add
("Count elements (expecting %d), and test the getkey function",
length);
- xbt_test_assert2(xbt_dict_length(dict) == length,
+ xbt_test_assert(xbt_dict_length(dict) == length,
"Announced length(%d) != %d.", xbt_dict_length(dict),
length);
key2, key);
}
- xbt_test_assert2(effective == length, "Effective length(%d) != %d.",
+ xbt_test_assert(effective == length, "Effective length(%d) != %d.",
effective, length);
}
XBT_TEST_UNIT("basic", test_dict_basic, "Basic usage: change, retrieve, traverse")
{
- xbt_test_add0("Traversal the null dictionary");
+ xbt_test_add("Traversal the null dictionary");
traverse(head);
- xbt_test_add0("Traversal and search the empty dictionary");
+ xbt_test_add("Traversal and search the empty dictionary");
head = xbt_dict_new();
traverse(head);
TRY {
}
xbt_dict_free(&head);
- xbt_test_add0("Traverse the full dictionary");
+ xbt_test_add("Traverse the full dictionary");
fill(&head);
count_check_get_key(head, 7);
search(head, "12a");
traverse(head);
- xbt_test_add0("Free the dictionary (twice)");
+ xbt_test_add("Free the dictionary (twice)");
xbt_dict_free(&head);
xbt_dict_free(&head);
/* CHANGING */
fill(&head);
count_check_get_key(head, 7);
- xbt_test_add0("Change 123 to 'Changed 123'");
+ xbt_test_add("Change 123 to 'Changed 123'");
xbt_dict_set(head, "123", strdup("Changed 123"), &free);
count_check_get_key(head, 7);
- xbt_test_add0("Change 123 back to '123'");
+ xbt_test_add("Change 123 back to '123'");
xbt_dict_set(head, "123", strdup("123"), &free);
count_check_get_key(head, 7);
- xbt_test_add0("Change 12a to 'Dummy 12a'");
+ xbt_test_add("Change 12a to 'Dummy 12a'");
xbt_dict_set(head, "12a", strdup("Dummy 12a"), &free);
count_check_get_key(head, 7);
- xbt_test_add0("Change 12a to '12a'");
+ xbt_test_add("Change 12a to '12a'");
xbt_dict_set(head, "12a", strdup("12a"), &free);
count_check_get_key(head, 7);
- xbt_test_add0("Traverse the resulting dictionary");
+ xbt_test_add("Traverse the resulting dictionary");
traverse(head);
/* RETRIEVE */
- xbt_test_add0("Search 123");
+ xbt_test_add("Search 123");
data = xbt_dict_get(head, "123");
xbt_test_assert(data);
xbt_test_assert(!strcmp("123", data));
search(head, "1234");
search(head, "123457");
- xbt_test_add0("Traverse the resulting dictionary");
+ xbt_test_add("Traverse the resulting dictionary");
traverse(head);
/* xbt_dict_dump(head,(void (*)(void*))&printf); */
- xbt_test_add0("Free the dictionary twice");
+ xbt_test_add("Free the dictionary twice");
xbt_dict_free(&head);
xbt_dict_free(&head);
- xbt_test_add0("Traverse the resulting dictionary");
+ xbt_test_add("Traverse the resulting dictionary");
traverse(head);
}
{
fill(&head);
count(head, 7);
- xbt_test_add0("Remove non existing data");
+ xbt_test_add("Remove non existing data");
TRY {
debuged_remove(head, "Does not exist");
}
xbt_dict_free(&head);
- xbt_test_add0
+ xbt_test_add
("Remove each data manually (traversing the resulting dictionary each time)");
fill(&head);
debuged_remove(head, "12a");
}
traverse(head);
- xbt_test_add0
+ xbt_test_add
("Free dict, create new fresh one, and then reset the dict");
xbt_dict_free(&head);
fill(&head);
count(head, 0);
traverse(head);
- xbt_test_add0("Free the dictionary twice");
+ xbt_test_add("Free the dictionary twice");
xbt_dict_free(&head);
xbt_dict_free(&head);
}
{
fill(&head);
- xbt_test_add0("Store NULL under 'null'");
+ xbt_test_add("Store NULL under 'null'");
xbt_dict_set(head, "null", NULL, NULL);
search_ext(head, "null", NULL);
- xbt_test_add0("Check whether I see it while traversing...");
+ xbt_test_add("Check whether I see it while traversing...");
{
xbt_dict_cursor_t cursor = NULL;
char *key;
xbt_dict_foreach(head, cursor, key, data) {
if (!key || !data || strcmp(key, data)) {
- xbt_test_log2("Seen: %s->%s", PRINTF_STR(key), PRINTF_STR(data));
+ xbt_test_log("Seen: %s->%s", PRINTF_STR(key), PRINTF_STR(data));
} else {
- xbt_test_log1("Seen: %s", PRINTF_STR(key));
+ xbt_test_log("Seen: %s", PRINTF_STR(key));
}
if (!strcmp(key, "null"))
found = 1;
}
- xbt_test_assert0(found,
+ xbt_test_assert(found,
"the key 'null', associated to NULL is not found");
}
xbt_dict_free(&head);
static void debuged_addi(xbt_dict_t head, uintptr_t key, uintptr_t data)
{
uintptr_t stored_data = 0;
- xbt_test_log2("Add %zu under %zu", data, key);
+ xbt_test_log("Add %zu under %zu", data, key);
xbt_dicti_set(head, key, data);
if (XBT_LOG_ISENABLED(xbt_dict, xbt_log_priority_debug)) {
fflush(stdout);
}
stored_data = xbt_dicti_get(head, key);
- xbt_test_assert3(stored_data == data,
+ xbt_test_assert(stored_data == data,
"Retrieved data (%zu) is not what I just stored (%zu) under key %zu",
stored_data, data, key);
}
XBT_TEST_UNIT("dicti", test_dict_scalar, "Scalar data and key management")
{
- xbt_test_add0("Fill in the dictionnary");
+ xbt_test_add("Fill in the dictionnary");
head = xbt_dict_new();
debuged_addi(head, 12, 12);
srand((unsigned int) time(NULL));
for (i = 0; i < 10; i++) {
- xbt_test_add2("CRASH test number %d (%d to go)", i + 1, 10 - i - 1);
- xbt_test_log0
+ xbt_test_add("CRASH test number %d (%d to go)", i + 1, 10 - i - 1);
+ xbt_test_log
("Fill the struct, count its elems and frees the structure");
- xbt_test_log1
+ xbt_test_log
("using 1000 elements with %d chars long randomized keys.",
SIZEOFKEY);
head = xbt_dict_new();
xbt_dict_set(head, key, key, &free);
data = xbt_dict_get(head, key);
- xbt_test_assert2(!strcmp(key, data),
+ xbt_test_assert(!strcmp(key, data),
"Retrieved value (%s) != Injected value (%s)", key,
data);
head = xbt_dict_new();
- xbt_test_add1("Fill %d elements, with keys being the number of element",
+ xbt_test_add("Fill %d elements, with keys being the number of element",
NB_ELM);
for (j = 0; j < NB_ELM; j++) {
/* if (!(j%1000)) { printf("."); fflush(stdout); } */
}
/*xbt_dict_dump(head,(void (*)(void*))&printf); */
- xbt_test_add0
+ xbt_test_add
("Count the elements (retrieving the key and data for each)");
i = countelems(head);
- xbt_test_log1("There is %d elements", i);
+ xbt_test_log("There is %d elements", i);
- xbt_test_add1("Search my %d elements 20 times", NB_ELM);
+ xbt_test_add("Search my %d elements 20 times", NB_ELM);
key = xbt_malloc(10);
for (i = 0; i < 20; i++) {
/* if (i%10) printf("."); else printf("%d",i/10); fflush(stdout); */
sprintf(key, "%d", j);
data = xbt_dict_get(head, key);
- xbt_test_assert2(!strcmp(key, (char *) data),
+ xbt_test_assert(!strcmp(key, (char *) data),
"with get, key=%s != data=%s", key, (char *) data);
data = xbt_dict_get_ext(head, key, strlen(key));
- xbt_test_assert2(!strcmp(key, (char *) data),
+ xbt_test_assert(!strcmp(key, (char *) data),
"with get_ext, key=%s != data=%s", key,
(char *) data);
}
}
free(key);
- xbt_test_add1("Remove my %d elements", NB_ELM);
+ xbt_test_add("Remove my %d elements", NB_ELM);
key = xbt_malloc(10);
for (j = 0; j < NB_ELM; j++) {
/* if (!(j%10000)) printf("."); fflush(stdout); */
free(key);
- xbt_test_add0("Free the structure (twice)");
+ xbt_test_add("Free the structure (twice)");
xbt_dict_free(&head);
xbt_dict_free(&head);
}
char *key;
- xbt_test_add0("Generic multicache CRASH test");
- xbt_test_log4
+ xbt_test_add("Generic multicache CRASH test");
+ xbt_test_log
(" Fill the struct and frees it %d times, using %d elements, "
"depth of multicache=%d, key size=%d", NB_TEST, NB_ELM, DEPTH,
KEY_SIZE);
data = xbt_multidict_get(mdict, keys);
- xbt_test_assert2(data && !strcmp((char *) data, key),
+ xbt_test_assert(data && !strcmp((char *) data, key),
"Retrieved value (%s) does not match the given one (%s)\n",
(char *) data, key);
}
unsigned int cursor;
int *iptr;
- xbt_test_add0("==== Traverse the empty dynar");
+ xbt_test_add("==== Traverse the empty dynar");
d = xbt_dynar_new(sizeof(int), NULL);
xbt_dynar_foreach(d, cursor, i) {
xbt_die( "Damnit, there is something in the empty dynar");
xbt_dynar_free(&d); /* free the struct twice here to check that it's ok, but freeing it only once */
/* in your code is naturally the way to go outside a regression test */
- xbt_test_add1
+ xbt_test_add
("==== Push %d int, set them again 3 times, traverse them, shift them",
NB_ELEM);
/* Populate_ints [doxygen cruft] */
for (cpt = 0; cpt < NB_ELEM; cpt++) {
xbt_dynar_push_as(d, int, cpt); /* This is faster (and possible only with scalars) */
/* xbt_dynar_push(d,&cpt); This would also work */
- xbt_test_log2("Push %d, length=%lu", cpt, xbt_dynar_length(d));
+ xbt_test_log("Push %d, length=%lu", cpt, xbt_dynar_length(d));
}
/* 2. Traverse manually the dynar */
for (cursor = 0; cursor < NB_ELEM; cursor++) {
iptr = xbt_dynar_get_ptr(d, cursor);
- xbt_test_assert2(cursor == *iptr,
+ xbt_test_assert(cursor == *iptr,
"The retrieved value is not the same than the injected one (%d!=%d)",
cursor, cpt);
}
/* 3. Traverse the dynar using the neat macro to that extend */
xbt_dynar_foreach(d, cursor, cpt) {
- xbt_test_assert2(cursor == cpt,
+ xbt_test_assert(cursor == cpt,
"The retrieved value is not the same than the injected one (%d!=%d)",
cursor, cpt);
}
cpt = 0;
xbt_dynar_foreach(d, cursor, i) {
- xbt_test_assert2(i == cpt,
+ xbt_test_assert(i == cpt,
"The retrieved value is not the same than the injected one (%d!=%d)",
i, cpt);
cpt++;
}
- xbt_test_assert2(cpt == NB_ELEM,
+ xbt_test_assert(cpt == NB_ELEM,
"Cannot retrieve my %d values. Last got one is %d",
NB_ELEM, cpt);
/* 4. Shift all the values */
for (cpt = 0; cpt < NB_ELEM; cpt++) {
xbt_dynar_shift(d, &i);
- xbt_test_assert2(i == cpt,
+ xbt_test_assert(i == cpt,
"The retrieved value is not the same than the injected one (%d!=%d)",
i, cpt);
- xbt_test_log2("Pop %d, length=%lu", cpt, xbt_dynar_length(d));
+ xbt_test_log("Pop %d, length=%lu", cpt, xbt_dynar_length(d));
}
/* 5. Free the resources */
xbt_dynar_free(&d); /* free the struct twice here to check that it's ok, but freeing it only once */
/* in your code is naturally the way to go outside a regression test */
- xbt_test_add1("==== Unshift/pop %d int", NB_ELEM);
+ xbt_test_add("==== Unshift/pop %d int", NB_ELEM);
d = xbt_dynar_new(sizeof(int), NULL);
for (cpt = 0; cpt < NB_ELEM; cpt++) {
xbt_dynar_unshift(d, &cpt);
}
for (cpt = 0; cpt < NB_ELEM; cpt++) {
i = xbt_dynar_pop_as(d, int);
- xbt_test_assert2(i == cpt,
+ xbt_test_assert(i == cpt,
"The retrieved value is not the same than the injected one (%d!=%d)",
i, cpt);
- xbt_test_log2("Pop %d, length=%lu", cpt, xbt_dynar_length(d));
+ xbt_test_log("Pop %d, length=%lu", cpt, xbt_dynar_length(d));
}
xbt_dynar_free(&d); /* This code is used both as example and as regression test, so we try to */
xbt_dynar_free(&d); /* free the struct twice here to check that it's ok, but freeing it only once */
/* in your code is naturally the way to go outside a regression test */
- xbt_test_add1
+ xbt_test_add
("==== Push %d int, insert 1000 int in the middle, shift everything",
NB_ELEM);
d = xbt_dynar_new(sizeof(int), NULL);
for (cpt = 0; cpt < NB_ELEM/2; cpt++) {
xbt_dynar_shift(d, &i);
- xbt_test_assert2(i == cpt,
+ xbt_test_assert(i == cpt,
"The retrieved value is not the same than the injected one at the begining (%d!=%d)",
i, cpt);
XBT_DEBUG("Pop %d, length=%lu", cpt, xbt_dynar_length(d));
}
for (cpt = 999; cpt >= 0; cpt--) {
xbt_dynar_shift(d, &i);
- xbt_test_assert2(i == cpt,
+ xbt_test_assert(i == cpt,
"The retrieved value is not the same than the injected one in the middle (%d!=%d)",
i, cpt);
}
for (cpt = 2500; cpt < NB_ELEM; cpt++) {
xbt_dynar_shift(d, &i);
- xbt_test_assert2(i == cpt,
+ xbt_test_assert(i == cpt,
"The retrieved value is not the same than the injected one at the end (%d!=%d)",
i, cpt);
}
xbt_dynar_free(&d); /* free the struct twice here to check that it's ok, but freeing it only once */
/* in your code is naturally the way to go outside a regression test */
- xbt_test_add1("==== Push %d int, remove 2000-4000. free the rest",
+ xbt_test_add("==== Push %d int, remove 2000-4000. free the rest",
NB_ELEM);
d = xbt_dynar_new(sizeof(int), NULL);
for (cpt = 0; cpt < NB_ELEM; cpt++)
for (cpt = 2000; cpt < 4000; cpt++) {
xbt_dynar_remove_at(d, 2000, &i);
- xbt_test_assert2(i == cpt,
+ xbt_test_assert(i == cpt,
"Remove a bad value. Got %d, expected %d", i, cpt);
XBT_DEBUG("remove %d, length=%lu", cpt, xbt_dynar_length(d));
}
unsigned int cursor;
int cpt;
- xbt_test_add1("==== Insert %d int, traverse them, remove them",NB_ELEM);
+ xbt_test_add("==== Insert %d int, traverse them, remove them",NB_ELEM);
/* Populate_ints [doxygen cruft] */
/* 1. Populate the dynar */
for (cpt = 0; cpt < NB_ELEM; cpt++) {
xbt_dynar_insert_at(d, cpt, &cpt);
- xbt_test_log2("Push %d, length=%lu", cpt, xbt_dynar_length(d));
+ xbt_test_log("Push %d, length=%lu", cpt, xbt_dynar_length(d));
}
/* 3. Traverse the dynar */
xbt_dynar_foreach(d, cursor, cpt) {
- xbt_test_assert2(cursor == cpt,
+ xbt_test_assert(cursor == cpt,
"The retrieved value is not the same than the injected one (%d!=%d)",
cursor, cpt);
}
for (cpt = 0; cpt < NB_ELEM; cpt++)
xbt_dynar_set_as(d, cpt, int, cpt);
xbt_dynar_foreach(d, cursor, cpt)
- xbt_test_assert2(cursor == cpt,
+ xbt_test_assert(cursor == cpt,
"The retrieved value is not the same than the injected one (%d!=%d)",
cursor, cpt);
for (cpt = 0; cpt < NB_ELEM; cpt++) {
int val;
xbt_dynar_remove_at(d,0,&val);
- xbt_test_assert2(cpt == val,
+ xbt_test_assert(cpt == val,
"The retrieved value is not the same than the injected one (%d!=%d)",
cursor, cpt);
}
- xbt_test_assert1(xbt_dynar_length(d) == 0,
+ xbt_test_assert(xbt_dynar_length(d) == 0,
"There is still %lu elements in the dynar after removing everything",
xbt_dynar_length(d));
xbt_dynar_free(&d);
/* ********************* */
- xbt_test_add1("==== Insert %d int in reverse order, traverse them, remove them",NB_ELEM);
+ xbt_test_add("==== Insert %d int in reverse order, traverse them, remove them",NB_ELEM);
d = xbt_dynar_new(sizeof(int), NULL);
for (cpt = NB_ELEM-1; cpt >=0; cpt--) {
xbt_dynar_replace(d, cpt, &cpt);
- xbt_test_log2("Push %d, length=%lu", cpt, xbt_dynar_length(d));
+ xbt_test_log("Push %d, length=%lu", cpt, xbt_dynar_length(d));
}
/* 3. Traverse the dynar */
xbt_dynar_foreach(d, cursor, cpt) {
- xbt_test_assert2(cursor == cpt,
+ xbt_test_assert(cursor == cpt,
"The retrieved value is not the same than the injected one (%d!=%d)",
cursor, cpt);
}
for (cpt =NB_ELEM-1; cpt >=0; cpt--) {
int val;
xbt_dynar_remove_at(d,xbt_dynar_length(d)-1,&val);
- xbt_test_assert2(cpt == val,
+ xbt_test_assert(cpt == val,
"The retrieved value is not the same than the injected one (%d!=%d)",
cursor, cpt);
}
- xbt_test_assert1(xbt_dynar_length(d) == 0,
+ xbt_test_assert(xbt_dynar_length(d) == 0,
"There is still %lu elements in the dynar after removing everything",
xbt_dynar_length(d));
xbt_dynar_free(&d);
unsigned int cursor;
double d1, d2;
- xbt_test_add0("==== Traverse the empty dynar");
+ xbt_test_add("==== Traverse the empty dynar");
d = xbt_dynar_new(sizeof(int), NULL);
xbt_dynar_foreach(d, cursor, cpt) {
- xbt_test_assert0(FALSE,
+ xbt_test_assert(FALSE,
"Damnit, there is something in the empty dynar");
}
xbt_dynar_free(&d); /* This code is used both as example and as regression test, so we try to */
xbt_dynar_free(&d); /* free the struct twice here to check that it's ok, but freeing it only once */
/* in your code is naturally the way to go outside a regression test */
- xbt_test_add0("==== Push/shift 5000 doubles");
+ xbt_test_add("==== Push/shift 5000 doubles");
d = xbt_dynar_new(sizeof(double), NULL);
for (cpt = 0; cpt < 5000; cpt++) {
d1 = (double) cpt;
}
xbt_dynar_foreach(d, cursor, d2) {
d1 = (double) cursor;
- xbt_test_assert2(d1 == d2,
+ xbt_test_assert(d1 == d2,
"The retrieved value is not the same than the injected one (%f!=%f)",
d1, d2);
}
for (cpt = 0; cpt < 5000; cpt++) {
d1 = (double) cpt;
xbt_dynar_shift(d, &d2);
- xbt_test_assert2(d1 == d2,
+ xbt_test_assert(d1 == d2,
"The retrieved value is not the same than the injected one (%f!=%f)",
d1, d2);
}
xbt_dynar_free(&d); /* free the struct twice here to check that it's ok, but freeing it only once */
/* in your code is naturally the way to go outside a regression test */
- xbt_test_add0("==== Unshift/pop 5000 doubles");
+ xbt_test_add("==== Unshift/pop 5000 doubles");
d = xbt_dynar_new(sizeof(double), NULL);
for (cpt = 0; cpt < 5000; cpt++) {
d1 = (double) cpt;
for (cpt = 0; cpt < 5000; cpt++) {
d1 = (double) cpt;
xbt_dynar_pop(d, &d2);
- xbt_test_assert2(d1 == d2,
+ xbt_test_assert(d1 == d2,
"The retrieved value is not the same than the injected one (%f!=%f)",
d1, d2);
}
- xbt_test_add0
+ xbt_test_add
("==== Push 5000 doubles, insert 1000 doubles in the middle, shift everything");
d = xbt_dynar_new(sizeof(double), NULL);
for (cpt = 0; cpt < 5000; cpt++) {
for (cpt = 0; cpt < 2500; cpt++) {
d1 = (double) cpt;
xbt_dynar_shift(d, &d2);
- xbt_test_assert2(d1 == d2,
+ xbt_test_assert(d1 == d2,
"The retrieved value is not the same than the injected one at the begining (%f!=%f)",
d1, d2);
XBT_DEBUG("Pop %d, length=%lu", cpt, xbt_dynar_length(d));
for (cpt = 999; cpt >= 0; cpt--) {
d1 = (double) cpt;
xbt_dynar_shift(d, &d2);
- xbt_test_assert2(d1 == d2,
+ xbt_test_assert(d1 == d2,
"The retrieved value is not the same than the injected one in the middle (%f!=%f)",
d1, d2);
}
for (cpt = 2500; cpt < 5000; cpt++) {
d1 = (double) cpt;
xbt_dynar_shift(d, &d2);
- xbt_test_assert2(d1 == d2,
+ xbt_test_assert(d1 == d2,
"The retrieved value is not the same than the injected one at the end (%f!=%f)",
d1, d2);
}
/* in your code is naturally the way to go outside a regression test */
- xbt_test_add0("==== Push 5000 double, remove 2000-4000. free the rest");
+ xbt_test_add("==== Push 5000 double, remove 2000-4000. free the rest");
d = xbt_dynar_new(sizeof(double), NULL);
for (cpt = 0; cpt < 5000; cpt++) {
d1 = (double) cpt;
for (cpt = 2000; cpt < 4000; cpt++) {
d1 = (double) cpt;
xbt_dynar_remove_at(d, 2000, &d2);
- xbt_test_assert2(d1 == d2,
+ xbt_test_assert(d1 == d2,
"Remove a bad value. Got %f, expected %f", d2, d1);
}
xbt_dynar_free(&d); /* This code is used both as example and as regression test, so we try to */
char buf[1024];
char *s1, *s2;
- xbt_test_add0("==== Traverse the empty dynar");
+ xbt_test_add("==== Traverse the empty dynar");
d = xbt_dynar_new(sizeof(char *), &xbt_free_ref);
xbt_dynar_foreach(d, iter, s1) {
- xbt_test_assert0(FALSE,
+ xbt_test_assert(FALSE,
"Damnit, there is something in the empty dynar");
}
xbt_dynar_free(&d); /* This code is used both as example and as regression test, so we try to */
xbt_dynar_free(&d); /* free the struct twice here to check that it's ok, but freeing it only once */
/* in your code is naturally the way to go outside a regression test */
- xbt_test_add1("==== Push %d strings, set them again 3 times, shift them",
+ xbt_test_add("==== Push %d strings, set them again 3 times, shift them",
NB_ELEM);
/* Populate_str [doxygen cruft] */
d = xbt_dynar_new(sizeof(char *), &xbt_free_ref);
for (cpt = 0; cpt < NB_ELEM; cpt++) {
sprintf(buf, "%d", cpt);
xbt_dynar_shift(d, &s2);
- xbt_test_assert2(!strcmp(buf, s2),
+ xbt_test_assert(!strcmp(buf, s2),
"The retrieved value is not the same than the injected one (%s!=%s)",
buf, s2);
free(s2);
xbt_dynar_free(&d); /* free the struct twice here to check that it's ok, but freeing it only once */
/* in your code is naturally the way to go outside a regression test */
- xbt_test_add1("==== Unshift, traverse and pop %d strings", NB_ELEM);
+ xbt_test_add("==== Unshift, traverse and pop %d strings", NB_ELEM);
d = xbt_dynar_new(sizeof(char **), &xbt_free_ref);
for (cpt = 0; cpt < NB_ELEM; cpt++) {
sprintf(buf, "%d", cpt);
/* 2. Traverse the dynar with the macro */
xbt_dynar_foreach(d, iter, s1) {
sprintf(buf, "%d", NB_ELEM - iter - 1);
- xbt_test_assert2(!strcmp(buf, s1),
+ xbt_test_assert(!strcmp(buf, s1),
"The retrieved value is not the same than the injected one (%s!=%s)",
buf, s1);
}
for (cpt = 0; cpt < NB_ELEM; cpt++) {
sprintf(buf, "%d", cpt);
xbt_dynar_pop(d, &s2);
- xbt_test_assert2(!strcmp(buf, s2),
+ xbt_test_assert(!strcmp(buf, s2),
"The retrieved value is not the same than the injected one (%s!=%s)",
buf, s2);
free(s2);
/* in your code is naturally the way to go outside a regression test */
- xbt_test_add2
+ xbt_test_add
("==== Push %d strings, insert %d strings in the middle, shift everything",
NB_ELEM, NB_ELEM / 5);
d = xbt_dynar_new(sizeof(char *), &xbt_free_ref);
for (cpt = 0; cpt < NB_ELEM / 2; cpt++) {
sprintf(buf, "%d", cpt);
xbt_dynar_shift(d, &s2);
- xbt_test_assert2(!strcmp(buf, s2),
+ xbt_test_assert(!strcmp(buf, s2),
"The retrieved value is not the same than the injected one at the begining (%s!=%s)",
buf, s2);
free(s2);
for (cpt = (NB_ELEM / 5) - 1; cpt >= 0; cpt--) {
sprintf(buf, "%d", cpt);
xbt_dynar_shift(d, &s2);
- xbt_test_assert2(!strcmp(buf, s2),
+ xbt_test_assert(!strcmp(buf, s2),
"The retrieved value is not the same than the injected one in the middle (%s!=%s)",
buf, s2);
free(s2);
for (cpt = NB_ELEM / 2; cpt < NB_ELEM; cpt++) {
sprintf(buf, "%d", cpt);
xbt_dynar_shift(d, &s2);
- xbt_test_assert2(!strcmp(buf, s2),
+ xbt_test_assert(!strcmp(buf, s2),
"The retrieved value is not the same than the injected one at the end (%s!=%s)",
buf, s2);
free(s2);
/* in your code is naturally the way to go outside a regression test */
- xbt_test_add3("==== Push %d strings, remove %d-%d. free the rest",
+ xbt_test_add("==== Push %d strings, remove %d-%d. free the rest",
NB_ELEM, 2 * (NB_ELEM / 5), 4 * (NB_ELEM / 5));
d = xbt_dynar_new(sizeof(char *), &xbt_free_ref);
for (cpt = 0; cpt < NB_ELEM; cpt++) {
for (cpt = 2 * (NB_ELEM / 5); cpt < 4 * (NB_ELEM / 5); cpt++) {
sprintf(buf, "%d", cpt);
xbt_dynar_remove_at(d, 2 * (NB_ELEM / 5), &s2);
- xbt_test_assert2(!strcmp(buf, s2),
+ xbt_test_assert(!strcmp(buf, s2),
"Remove a bad value. Got %s, expected %s", s2, buf);
free(s2);
}
xbt_dynar_t d;
xbt_thread_t pusher, poper;
- xbt_test_add0("==== Have a pusher and a popper on the dynar");
+ xbt_test_add("==== Have a pusher and a popper on the dynar");
d = xbt_dynar_new_sync(sizeof(int), NULL);
pusher = xbt_thread_create("pusher", pusher_f, d, 0 /*not joinable */ );
poper = xbt_thread_create("poper", poper_f, d, 0 /*not joinable */ );
xbt_ex_t ex;
volatile int n = 1;
- xbt_test_add0("basic nested control flow");
+ xbt_test_add("basic nested control flow");
TRY {
if (n != 1)
- xbt_test_fail1("M1: n=%d (!= 1)", n);
+ xbt_test_fail("M1: n=%d (!= 1)", n);
n++;
TRY {
if (n != 2)
- xbt_test_fail1("M2: n=%d (!= 2)", n);
+ xbt_test_fail("M2: n=%d (!= 2)", n);
n++;
THROW0(unknown_error, 0, "something");
}
CATCH(ex) {
if (n != 3)
- xbt_test_fail1("M3: n=%d (!= 3)", n);
+ xbt_test_fail("M3: n=%d (!= 3)", n);
n++;
xbt_ex_free(ex);
}
n++;
TRY {
if (n != 5)
- xbt_test_fail1("M2: n=%d (!= 5)", n);
+ xbt_test_fail("M2: n=%d (!= 5)", n);
n++;
THROW0(unknown_error, 0, "something");
}
CATCH(ex) {
if (n != 6)
- xbt_test_fail1("M3: n=%d (!= 6)", n);
+ xbt_test_fail("M3: n=%d (!= 6)", n);
n++;
RETHROW;
n++;
}
- xbt_test_fail1("MX: n=%d (shouldn't reach this point)", n);
+ xbt_test_fail("MX: n=%d (shouldn't reach this point)", n);
}
CATCH(ex) {
if (n != 7)
- xbt_test_fail1("M4: n=%d (!= 7)", n);
+ xbt_test_fail("M4: n=%d (!= 7)", n);
n++;
xbt_ex_free(ex);
}
if (n != 8)
- xbt_test_fail1("M5: n=%d (!= 8)", n);
+ xbt_test_fail("M5: n=%d (!= 8)", n);
}
XBT_TEST_UNIT("value", test_value, "exception value passing")
THROW0(unknown_error, 2, "toto");
}
CATCH(ex) {
- xbt_test_add0("exception value passing");
+ xbt_test_add("exception value passing");
if (ex.category != unknown_error)
- xbt_test_fail1("category=%d (!= 1)", ex.category);
+ xbt_test_fail("category=%d (!= 1)", ex.category);
if (ex.value != 2)
- xbt_test_fail1("value=%d (!= 2)", ex.value);
+ xbt_test_fail("value=%d (!= 2)", ex.value);
if (strcmp(ex.msg, "toto"))
- xbt_test_fail1("message=%s (!= toto)", ex.msg);
+ xbt_test_fail("message=%s (!= toto)", ex.msg);
xbt_ex_free(ex);
}
}
v2 = 5678;
THROW0(unknown_error, 0, "toto");
} CATCH(ex) {
- xbt_test_add0("variable preservation");
+ xbt_test_add("variable preservation");
if (r1 != 1234)
- xbt_test_fail1("r1=%d (!= 1234)", r1);
+ xbt_test_fail("r1=%d (!= 1234)", r1);
if (v1 != 1234)
- xbt_test_fail1("v1=%d (!= 1234)", v1);
+ xbt_test_fail("v1=%d (!= 1234)", v1);
/* r2 is allowed to be destroyed because not volatile */
if (v2 != 5678)
- xbt_test_fail1("v2=%d (!= 5678)", v2);
+ xbt_test_fail("v2=%d (!= 5678)", v2);
xbt_ex_free(ex);
}
}
volatile int v1;
int c;
- xbt_test_add0("cleanup handling");
+ xbt_test_add("cleanup handling");
v1 = 1234;
c = 0;
THROW0(1, 2, "blah");
} TRY_CLEANUP {
if (v1 != 5678)
- xbt_test_fail1("v1 = %d (!= 5678)", v1);
+ xbt_test_fail("v1 = %d (!= 5678)", v1);
c = 1;
}
CATCH(ex) {
if (v1 != 5678)
- xbt_test_fail1("v1 = %d (!= 5678)", v1);
+ xbt_test_fail("v1 = %d (!= 5678)", v1);
if (!(ex.category == 1 && ex.value == 2 && !strcmp(ex.msg, "blah")))
- xbt_test_fail0("unexpected exception contents");
+ xbt_test_fail("unexpected exception contents");
xbt_ex_free(ex);
}
if (!c)
- xbt_test_fail0("xbt_ex_free not executed");
+ xbt_test_fail("xbt_ex_free not executed");
}
XBT_TEST_UNIT("basic", test_parmap_basic, "Basic usage")
{
- xbt_test_add0("Create the parmap");
+ xbt_test_add("Create the parmap");
unsigned long i,j;
xbt_dynar_t data = xbt_dynar_new(sizeof(void *), NULL);
elm->data = xbt_strdup(data);
- xbt_test_log2("Add %s (->%s)", name, data);
+ xbt_test_log("Add %s (->%s)", name, data);
xbt_set_add(set, (xbt_set_elm_t) elm, &my_elem_free);
}
static void fill(xbt_set_t * set)
{
- xbt_test_add0("Fill in the data set");
+ xbt_test_add("Fill in the data set");
*set = xbt_set_new();
debuged_add(*set, "12", "12");
debuged_add(*set, "12b", "12b");
debuged_add(*set, "123", "123");
debuged_add(*set, "123456", "123456");
- xbt_test_log0("Child becomes child of what to add");
+ xbt_test_log("Child becomes child of what to add");
debuged_add(*set, "1234", "1234");
- xbt_test_log0("Need of common ancestor");
+ xbt_test_log("Need of common ancestor");
debuged_add(*set, "123457", "123457");
}
{
my_elem_t elm;
- xbt_test_add1("Search by name %s", key);
+ xbt_test_add("Search by name %s", key);
elm = (my_elem_t) xbt_set_get_by_name(head, key);
- xbt_test_log2(" Found %s (under ID %d)\n",
+ xbt_test_log(" Found %s (under ID %d)\n",
elm ? elm->data : "(null)", elm ? elm->ID : -1);
if (strcmp(key, elm->name))
THROW2(mismatch_error, 0, "The key (%s) is not the one expected (%s)",
{
my_elem_t elm;
- xbt_test_add1("Search by id %d", id);
+ xbt_test_add("Search by id %d", id);
elm = (my_elem_t) xbt_set_get_by_id(head, id);
- xbt_test_log2("Found %s (data %s)",
+ xbt_test_log("Found %s (data %s)",
elm ? elm->name : "(null)", elm ? elm->data : "(null)");
if (id != elm->ID)
THROW2(mismatch_error, 0,
my_elem_t elm = NULL;
xbt_set_foreach(set, cursor, elm) {
- xbt_test_assert0(elm, "Dude ! Got a null elm during traversal!");
- xbt_test_log3("Id(%d): %s->%s\n", elm->ID, elm->name, elm->data);
- xbt_test_assert2(!strcmp(elm->name, elm->data),
+ xbt_test_assert(elm, "Dude ! Got a null elm during traversal!");
+ xbt_test_log("Id(%d): %s->%s\n", elm->ID, elm->name, elm->data);
+ xbt_test_assert(!strcmp(elm->name, elm->data),
"Key(%s) != value(%s). Abording", elm->name,
elm->data);
}
{
xbt_ex_t e;
- xbt_test_add1("Search %s (expected not to be found)", data);
+ xbt_test_add("Search %s (expected not to be found)", data);
TRY {
xbt_set_get_by_name(set, data);
THROW1(unknown_error, 0,
{
set = NULL;
- xbt_test_add0("Traverse the empty set");
+ xbt_test_add("Traverse the empty set");
traverse(set);
- xbt_test_add0("Free a data set");
+ xbt_test_add("Free a data set");
fill(&set);
xbt_set_free(&set);
- xbt_test_add0("Free the NULL data set");
+ xbt_test_add("Free the NULL data set");
xbt_set_free(&set);
}
{
fill(&set);
- xbt_test_add0("Change 123 to 'Changed 123'");
+ xbt_test_add("Change 123 to 'Changed 123'");
debuged_add(set, "123", "Changed 123");
- xbt_test_add0("Change 123 back to '123'");
+ xbt_test_add("Change 123 back to '123'");
debuged_add(set, "123", "123");
- xbt_test_add0("Change 12a to 'Dummy 12a'");
+ xbt_test_add("Change 12a to 'Dummy 12a'");
debuged_add(set, "12a", "Dummy 12a");
- xbt_test_add0("Change 12a to '12a'");
+ xbt_test_add("Change 12a to '12a'");
debuged_add(set, "12a", "12a");
/* xbt_dict_dump(head,(void (*)(void*))&printf); */
- xbt_test_add0("Traverse the resulting data set");
+ xbt_test_add("Traverse the resulting data set");
traverse(set);
}
{
my_elem_t elm;
- xbt_test_add0("Search 123");
+ xbt_test_add("Search 123");
elm = (my_elem_t) xbt_set_get_by_name(set, "123");
- xbt_test_assert0(elm, "elm must be there");
+ xbt_test_assert(elm, "elm must be there");
xbt_assert(!strcmp("123", elm->data));
search_not_found(set, "Can't be found");
search_id(set, 5, "1234");
search_id(set, 6, "123457");
- xbt_test_add0("Traverse the resulting data set");
+ xbt_test_add("Traverse the resulting data set");
traverse(set);
/* xbt_dict_dump(head,(void (*)(void*))&printf); */
- xbt_test_add0("Free the data set (twice)");
+ xbt_test_add("Free the data set (twice)");
xbt_set_free(&set);
xbt_set_free(&set);
- xbt_test_add0("Traverse the resulting data set");
+ xbt_test_add("Traverse the resulting data set");
traverse(set);
}
debuged_add(set, "12anew", "12anew");
elm = (my_elem_t) xbt_set_get_by_id(set, 1);
- xbt_test_assert1(elm->ID == 1, "elm->ID is %d but should be 1", elm->ID);
+ xbt_test_assert(elm->ID == 1, "elm->ID is %d but should be 1", elm->ID);
xbt_set_free(&set);
}
obj1->name = "Obj 1";
obj2->name = "Obj 2";
- xbt_test_add0("Basic usage");
- xbt_test_log3("%p %p %ld\n", obj1, &(obj1->setB),
+ xbt_test_add("Basic usage");
+ xbt_test_log("%p %p %ld\n", obj1, &(obj1->setB),
(long) ((char *) &(obj1->setB) - (char *) obj1));
setA = xbt_swag_new(xbt_swag_offset(*obj1, setA));
xbt_swag_remove(obj1, setB);
/* xbt_swag_remove(obj2, setB); */
- xbt_test_add0("Traverse set A");
+ xbt_test_add("Traverse set A");
xbt_swag_foreach(obj, setA) {
- xbt_test_log1("Saw: %s", obj->name);
+ xbt_test_log("Saw: %s", obj->name);
}
- xbt_test_add0("Traverse set B");
+ xbt_test_add("Traverse set B");
xbt_swag_foreach(obj, setB) {
- xbt_test_log1("Saw: %s", obj->name);
+ xbt_test_log("Saw: %s", obj->name);
}
- xbt_test_add0("Ensure set content and length");
+ xbt_test_add("Ensure set content and length");
xbt_test_assert(xbt_swag_belongs(obj1, setA));
xbt_test_assert(xbt_swag_belongs(obj2, setA));
char hash[41];
xbt_sha(clear, hash);
- xbt_test_add1("==== Test with '%s'", clear);
- xbt_test_assert3(!memcmp(hash, hashed, 40), "Wrong sha: %40s!=%40s (%s)",
+ xbt_test_add("==== Test with '%s'", clear);
+ xbt_test_assert(!memcmp(hash, hashed, 40), "Wrong sha: %40s!=%40s (%s)",
hash, hashed, mycmp(hash, hashed, 40));
}
#include "xbt/str.h"
#define mytest(name, input, expected) \
- xbt_test_add0(name); \
+ xbt_test_add(name); \
d=xbt_str_split_quoted(input); \
s=xbt_str_join(d,"XXX"); \
- xbt_test_assert3(!strcmp(s,expected),\
+ xbt_test_assert(!strcmp(s,expected),\
"Input (%s) leads to (%s) instead of (%s)", \
input,s,expected);\
free(s); \
}
#define mytest_str(name, input, separator, expected) \
- xbt_test_add0(name); \
+ xbt_test_add(name); \
d=xbt_str_split_str(input, separator); \
s=xbt_str_join(d,"XXX"); \
- xbt_test_assert3(!strcmp(s,expected),\
+ xbt_test_assert(!strcmp(s,expected),\
"Input (%s) leads to (%s) instead of (%s)", \
input,s,expected);\
free(s); \
xbt_strbuff_append(sb, input);
xbt_strbuff_varsubst(sb, p);
xbt_dict_free(&p);
- xbt_test_assert4(!strcmp(sb->data, expected),
+ xbt_test_assert(!strcmp(sb->data, expected),
"Input (%s) with patterns (%s) leads to (%s) instead of (%s)",
input, patterns, sb->data, expected);
xbt_strbuff_free(sb);
XBT_TEST_SUITE("xbt_strbuff", "String Buffers");
XBT_TEST_UNIT("xbt_strbuff_substitute", test_strbuff_substitute, "test the function xbt_strbuff_substitute")
{
- xbt_test_add0("Empty");
+ xbt_test_add("Empty");
mytest("", "", "");
- xbt_test_add0("Value shorter, no braces, only variable");
+ xbt_test_add("Value shorter, no braces, only variable");
mytest("$tutu", "tutu=t", "t");
- xbt_test_add0("Value shorter, braces, only variable");
+ xbt_test_add("Value shorter, braces, only variable");
mytest("${tutu}", "tutu=t", "t");
- xbt_test_add0("Value shorter, no braces, data after");
+ xbt_test_add("Value shorter, no braces, data after");
mytest("$tutu toto", "tutu=t", "t toto");
- xbt_test_add0("Value shorter, braces, data after");
+ xbt_test_add("Value shorter, braces, data after");
mytest("${tutu} toto", "tutu=t", "t toto");
- xbt_test_add0("Value shorter, no braces, data before");
+ xbt_test_add("Value shorter, no braces, data before");
mytest("toto $tutu", "tutu=t", "toto t");
- xbt_test_add0("Value shorter, braces, data before");
+ xbt_test_add("Value shorter, braces, data before");
mytest("toto ${tutu}", "tutu=t", "toto t");
- xbt_test_add0("Value shorter, no braces, data before and after");
+ xbt_test_add("Value shorter, no braces, data before and after");
mytest("toto $tutu tata", "tutu=t", "toto t tata");
- xbt_test_add0("Value shorter, braces, data before and after");
+ xbt_test_add("Value shorter, braces, data before and after");
mytest("toto ${tutu} tata", "tutu=t", "toto t tata");
- xbt_test_add0("Value as long, no braces, only variable");
+ xbt_test_add("Value as long, no braces, only variable");
mytest("$tutu", "tutu=12345", "12345");
- xbt_test_add0("Value as long, braces, only variable");
+ xbt_test_add("Value as long, braces, only variable");
mytest("${tutu}", "tutu=1234567", "1234567");
- xbt_test_add0("Value as long, no braces, data after");
+ xbt_test_add("Value as long, no braces, data after");
mytest("$tutu toto", "tutu=12345", "12345 toto");
- xbt_test_add0("Value as long, braces, data after");
+ xbt_test_add("Value as long, braces, data after");
mytest("${tutu} toto", "tutu=1234567", "1234567 toto");
- xbt_test_add0("Value as long, no braces, data before");
+ xbt_test_add("Value as long, no braces, data before");
mytest("toto $tutu", "tutu=12345", "toto 12345");
- xbt_test_add0("Value as long, braces, data before");
+ xbt_test_add("Value as long, braces, data before");
mytest("toto ${tutu}", "tutu=1234567", "toto 1234567");
- xbt_test_add0("Value as long, no braces, data before and after");
+ xbt_test_add("Value as long, no braces, data before and after");
mytest("toto $tutu tata", "tutu=12345", "toto 12345 tata");
- xbt_test_add0("Value as long, braces, data before and after");
+ xbt_test_add("Value as long, braces, data before and after");
mytest("toto ${tutu} tata", "tutu=1234567", "toto 1234567 tata");
- xbt_test_add0("Value longer, no braces, only variable");
+ xbt_test_add("Value longer, no braces, only variable");
mytest("$t", "t=tututu", "tututu");
- xbt_test_add0("Value longer, braces, only variable");
+ xbt_test_add("Value longer, braces, only variable");
mytest("${t}", "t=tututu", "tututu");
- xbt_test_add0("Value longer, no braces, data after");
+ xbt_test_add("Value longer, no braces, data after");
mytest("$t toto", "t=tututu", "tututu toto");
- xbt_test_add0("Value longer, braces, data after");
+ xbt_test_add("Value longer, braces, data after");
mytest("${t} toto", "t=tututu", "tututu toto");
- xbt_test_add0("Value longer, no braces, data before");
+ xbt_test_add("Value longer, no braces, data before");
mytest("toto $t", "t=tututu", "toto tututu");
- xbt_test_add0("Value longer, braces, data before");
+ xbt_test_add("Value longer, braces, data before");
mytest("toto ${t}", "t=tututu", "toto tututu");
- xbt_test_add0("Value longer, no braces, data before and after");
+ xbt_test_add("Value longer, no braces, data before and after");
mytest("toto $t tata", "t=tututu", "toto tututu tata");
- xbt_test_add0("Value longer, braces, data before and after");
+ xbt_test_add("Value longer, braces, data before and after");
mytest("toto ${t} tata", "t=tututu", "toto tututu tata");
- xbt_test_add0("Value much longer, no braces, only variable");
+ xbt_test_add("Value much longer, no braces, only variable");
mytest("$t", "t=" force_resize, force_resize);
- xbt_test_add0("Value much longer, no braces, data after");
+ xbt_test_add("Value much longer, no braces, data after");
mytest("$t toto", "t=" force_resize, force_resize " toto");
- xbt_test_add0("Value much longer, braces, data after");
+ xbt_test_add("Value much longer, braces, data after");
mytest("${t} toto", "t=" force_resize, force_resize " toto");
- xbt_test_add0("Value much longer, no braces, data before");
+ xbt_test_add("Value much longer, no braces, data before");
mytest("toto $t", "t=" force_resize, "toto " force_resize);
- xbt_test_add0("Value much longer, braces, data before");
+ xbt_test_add("Value much longer, braces, data before");
mytest("toto ${t}", "t=" force_resize, "toto " force_resize);
- xbt_test_add0("Value much longer, no braces, data before and after");
+ xbt_test_add("Value much longer, no braces, data before and after");
mytest("toto $t tata", "t=" force_resize, "toto " force_resize " tata");
- xbt_test_add0("Value much longer, braces, data before and after");
+ xbt_test_add("Value much longer, braces, data before and after");
mytest("toto ${t} tata", "t=" force_resize,
"toto " force_resize " tata");
- xbt_test_add0("Escaped $");
+ xbt_test_add("Escaped $");
mytest("\\$tutu", "tutu=t", "\\$tutu");
- xbt_test_add0("Space in var name (with braces)");
+ xbt_test_add("Space in var name (with braces)");
mytest("${tu ti}", "tu_ti=t", "t");
- xbt_test_add0("Two variables");
+ xbt_test_add("Two variables");
mytest("$toto $tutu", "toto=1 tutu=2", "1 2");
// Commented: I'm too lazy to do a memmove in var name to remove the backslash after use.
// Users should use braces.
- // xbt_test_add0("Escaped space in var name", "$tu\\ ti", "tu_ti=t", "t");
+ // xbt_test_add("Escaped space in var name", "$tu\\ ti", "tu_ti=t", "t");
- xbt_test_add0("Default value");
+ xbt_test_add("Default value");
mytest("${t:-toto}", "", "toto");
- xbt_test_add0("Useless default value (variable already defined)");
+ xbt_test_add("Useless default value (variable already defined)");
mytest("${t:-toto}", "t=TRUC", "TRUC");
}
int i, cpt;
unsigned int cursor;
- xbt_test_add1
+ xbt_test_add
("==== Push %d int, add 100 to each of them in parallel and check the results",
NB_ELEM);
d = xbt_dynar_new(sizeof(int), NULL);
for (cpt = 0; cpt < NB_ELEM; cpt++) {
xbt_dynar_push_as(d, int, cpt); /* This is faster (and possible only with scalars) */
- xbt_test_log2("Push %d, length=%lu", cpt, xbt_dynar_length(d));
+ xbt_test_log("Push %d, length=%lu", cpt, xbt_dynar_length(d));
}
xbt_dynar_dopar(d, add100);
cpt = 100;
xbt_dynar_foreach(d, cursor, i) {
- xbt_test_assert2(i == cpt,
+ xbt_test_assert(i == cpt,
"The retrieved value is not the expected one (%d!=%d)",
i, cpt);
cpt++;