2004-07-14 22:04:31 +04:00
|
|
|
#include "ompi_config.h"
|
|
|
|
#include "util/numtostr.h"
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
2004-08-10 01:24:20 +04:00
|
|
|
#include "support.h"
|
|
|
|
|
2004-07-14 22:04:31 +04:00
|
|
|
int
|
|
|
|
main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
char * tst;
|
|
|
|
char * expected;
|
2004-08-10 01:24:20 +04:00
|
|
|
|
|
|
|
test_init("ompi_numtostr_t");
|
2004-07-14 22:04:31 +04:00
|
|
|
|
2004-10-31 21:06:10 +03:00
|
|
|
tst = ompi_ltostr(10);
|
2004-07-14 22:04:31 +04:00
|
|
|
expected = malloc(sizeof(long) * 8);
|
|
|
|
snprintf(expected, sizeof(long) * 8, "%d", 10);
|
|
|
|
if (strcmp(tst, expected) != 0) {
|
2004-10-31 21:06:10 +03:00
|
|
|
test_failure("ompi_ltostr test failed");
|
2004-07-14 22:04:31 +04:00
|
|
|
}
|
2004-08-10 01:24:20 +04:00
|
|
|
else {
|
|
|
|
test_success();
|
|
|
|
}
|
|
|
|
|
2004-07-14 22:04:31 +04:00
|
|
|
free(tst);
|
|
|
|
free(expected);
|
|
|
|
|
2004-10-31 21:06:10 +03:00
|
|
|
tst = ompi_dtostr(5.32);
|
2004-07-14 22:04:31 +04:00
|
|
|
expected = malloc(sizeof(long) * 8);
|
|
|
|
snprintf(expected, sizeof(long) * 8, "%f", 5.32);
|
|
|
|
if (strcmp(tst, expected) != 0) {
|
2004-10-31 21:06:10 +03:00
|
|
|
test_failure("ompi_dtostr test failed");
|
2004-08-10 01:24:20 +04:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
test_success();
|
2004-07-14 22:04:31 +04:00
|
|
|
}
|
2004-08-10 01:24:20 +04:00
|
|
|
|
|
|
|
test_finalize();
|
2004-07-14 22:04:31 +04:00
|
|
|
|
|
|
|
return 0;
|
2004-08-10 01:24:20 +04:00
|
|
|
}
|