update the struct test so that field c of the test struct is of type double

This commit is contained in:
2020-03-09 13:49:09 +01:00
parent fc16663dae
commit 1f8de66751
3 changed files with 12 additions and 12 deletions

View File

@@ -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);

View File

@@ -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);

View File

@@ -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;
}