1
1
openmpi/test/util/ompi_numtostr.c
2016-11-22 15:03:20 -08:00

44 строки
808 B
C

#include "ompi_config.h"
#include "opal/util/numtostr.h"
#include <string.h>
#include <stdio.h>
#include "support.h"
int
main(int argc, char *argv[])
{
char * tst;
char * expected;
test_init("ompi_numtostr_t");
tst = opal_ltostr(10);
expected = malloc(sizeof(long) * 8);
snprintf(expected, sizeof(long) * 8, "%d", 10);
if (strcmp(tst, expected) != 0) {
test_failure("opal_ltostr test failed");
}
else {
test_success();
}
free(tst);
free(expected);
tst = opal_dtostr(5.32);
expected = malloc(sizeof(long) * 8);
snprintf(expected, sizeof(long) * 8, "%f", 5.32);
if (strcmp(tst, expected) != 0) {
test_failure("opal_dtostr test failed");
}
else {
test_success();
}
test_finalize();
return 0;
}