feat: add basic math and random_int funcs

This commit is contained in:
Matthieu Bessat 2022-04-30 18:01:22 +02:00
parent a62dd411aa
commit cb2a1df61f
5 changed files with 149 additions and 18 deletions

View file

@ -57,4 +57,16 @@ void test_evaluation()
evaluate("(abs((0-1)*2)) + abs(2)", &resVal, &resType);
assert(resType == TYPE_INT);
assert(4 == resVal);
}
evaluate("exp(2)-1", &resVal, &resType);
assert(resType == TYPE_FLOAT);
assert(float_almost_equal(6.389, get_float_from_int_rep(resVal)));
evaluate("(cos(2)^2)+(sin(2)^2)", &resVal, &resType);
assert(resType == TYPE_FLOAT);
assert(float_almost_equal(1, get_float_from_int_rep(resVal)));
evaluate("random_int(1, 100)", &resVal, &resType);
assert(resType == TYPE_INT);
printf(" - random int: %d \n", resVal);
}