to_float.c
tmi2/v21.7a10/testsuite/single/efuns/to_float.c · 460 B
From the archive tmi2_mudos_v1.tar.gz
Download the archive « Back to the archive contents
inherit "/inherit/tests";
int test(int which) {
int i = 5;
float f = 6.7;
switch (which) {
case 0:
describe_test("int");
f = to_float(i);
return (f == 5.0);
case 1:
describe_test("implicit int");
f = i;
return (f == 5.0);
case 2:
describe_test("string");
f = to_float("1.23");
return (f == 1.23);
case 3:
describe_test("garbage string");
f = to_float("ajdfj");
return (f == 0.00);
default:
return -1;
}
}