to_int.c

tmi2/v21.7a10/testsuite/single/efuns/to_int.c · 445 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("float");
	i = to_int(f);
	return (i == 6);
    case 1:
	describe_test("implicit float");
	i = f;
	return (i == 6);
    case 2:
	describe_test("string");
	i = to_int("7");
	return (i == 7);
    case 3:
	describe_test("garbage string");
	i = to_int("ajdfj");
	return (i == 0);
    default:
	return -1;
    }
}

Site Stats

Snippets: 1791
Codebases: 571