2004-07-14 22:04:31 +04:00
|
|
|
#include "ompi_config.h"
|
2005-07-04 05:36:20 +04:00
|
|
|
#include "opal/util/numtostr.h"
|
2004-07-14 22:04:31 +04:00
|
|
|
|
|
|
|
#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
|
|
|
|
2005-07-04 05:36:20 +04:00
|
|
|
tst = opal_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) {
|
2005-07-04 05:36:20 +04:00
|
|
|
test_failure("opal_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);
|
|
|
|
|
2005-07-04 05:36:20 +04:00
|
|
|
tst = opal_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) {
|
2005-07-04 05:36:20 +04:00
|
|
|
test_failure("opal_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
|
|
|
}
|