diff --git a/src/test/struct/struct.c b/src/test/struct/struct.c index c6d31e7..c654a8b 100644 --- a/src/test/struct/struct.c +++ b/src/test/struct/struct.c @@ -35,11 +35,11 @@ int struct_testExpected(char *name, long expected, long result) int testStructCreation() { printf("\nStruct creation tests\n"); - struct testStruct* result = getTestStruct(1, false, 20); + struct testStruct* result = getTestStruct(1, false, 23.3); struct_testExpected("init field a", 1, result->a); struct_testExpected("init field b", false, result->b); - struct_testExpected("init field c", 20, result->c); + struct_testExpected("init field c", 23.3, result->c); free(result); @@ -58,11 +58,11 @@ int testStructCreation() { int testStructGet() { printf("\nStruct getter tests\n"); - struct testStruct* result = getTestStruct(1, false, 20); + struct testStruct* result = getTestStruct(1, false, 23.3); struct_testExpected("get field a", 1, getStructFieldA(result)); struct_testExpected("get field b", false, getStructFieldB(result)); - struct_testExpected("get field c", 20, getStructFieldC(result)); + struct_testExpected("get field c", 23.3, getStructFieldC(result)); free(result); diff --git a/src/test/struct/struct.h b/src/test/struct/struct.h index 80e68a8..459e30c 100644 --- a/src/test/struct/struct.h +++ b/src/test/struct/struct.h @@ -4,7 +4,7 @@ struct testStruct { long a; bool b; - long c; + double c; }; struct testStructRec @@ -13,16 +13,16 @@ struct testStructRec struct testStructRec *b; }; -struct testStruct* getTestStruct(long a, bool b, long c); +struct testStruct* getTestStruct(long a, bool b, double c); struct testStructRec* getTestStructRec(long a, struct testStructRec* b); long getStructFieldA(struct testStruct *); bool getStructFieldB(struct testStruct *); -long getStructFieldC(struct testStruct *); +double getStructFieldC(struct testStruct *); struct testStruct *setStructFieldA(struct testStruct *t, long a); struct testStruct *setStructFieldB(struct testStruct *t, bool b); -struct testStruct *setStructFieldC(struct testStruct *t, long c); +struct testStruct *setStructFieldC(struct testStruct *t, double c); long getStructFieldRecA(struct testStructRec *t); struct testStructRec *getStructFieldRecB(struct testStructRec *t); diff --git a/src/test/test.k b/src/test/test.k index 0f98231..395afa2 100644 --- a/src/test/test.k +++ b/src/test/test.k @@ -418,7 +418,7 @@ function mixdiv(x: float, y: int): float { struct testStruct { a: int; b: bool; - c: int; + c: float; } struct testStructRec { @@ -426,7 +426,7 @@ struct testStructRec { b: testStructRec; } -function getTestStruct(a: int, b: bool, c: int): testStruct { +function getTestStruct(a: int, b: bool, c: float): testStruct { return create testStruct(a, b, c); } @@ -442,7 +442,7 @@ function getStructFieldB(t: testStruct): bool { return t.b; } -function getStructFieldC(t: testStruct): int { +function getStructFieldC(t: testStruct): float { return t.c; } @@ -456,7 +456,7 @@ function setStructFieldB(t: testStruct, b: bool): testStruct { return t; } -function setStructFieldC(t: testStruct, c: int): testStruct { +function setStructFieldC(t: testStruct, c: float): testStruct { t.c = c; return t; }