diff --git a/test/airthmetic.cpp b/test/arithmetic.cpp similarity index 100% rename from test/airthmetic.cpp rename to test/arithmetic.cpp diff --git a/test/functions.cpp b/test/functions.cpp index 3342589..5c42735 100644 --- a/test/functions.cpp +++ b/test/functions.cpp @@ -30,29 +30,73 @@ int main() { ); _TEST_ASSERT( - _TEST_NO_EXCEPTION(holds_alternative(execute("double a(int b, double c, int d) { return b+c+d; };"))), + _TEST_NO_EXCEPTION(holds_alternative(execute(R"( + double a(int b, double c, int d) { + return b+c+d; + } + )"))), "Déclaration de fonction", true ); _TEST_ASSERT( - _TEST_IS_EXCEPTION(execute("int a(int b) { int c(int d) {return d;} return c(b); };"), ErrorType::NestedFunction), + _TEST_IS_EXCEPTION(execute(R"( + int a(int b) { + int c(int d) { + return d; + } + return c(b); + }; + )"), + ErrorType::NestedFunction + ), "Fonctions imbriquées", true ); _TEST_ASSERT( - _TEST_NO_EXCEPTION(get(execute("int sum(int a, int b) {return a+b;}; sum(20, 7);")) == 27), + _TEST_NO_EXCEPTION(get(execute(R"( + int sum(int a, int b) { + return a+b; + } + sum(20, 7); + )")) == 27), "Exécution de fonction", true ); _TEST_ASSERT( - _TEST_NO_EXCEPTION(get(execute("int recurse(int a) {if (a < 27) {return recurse(a+1);} else {return a;}}; recurse(0);")) == 27), + _TEST_NO_EXCEPTION(get(execute(R"( + int recurse(int a) { + if (a < 27) + return recurse(a+1); + else + return a; + }; + recurse(0); + )")) == 27), "Fonction récursive", true ); + _TEST_ASSERT( + _TEST_NO_EXCEPTION(get(execute(R"( + int x(int a); + int y(int a) { + return x(a); + } + int x(int a) { + if (a < 75) { + return y(a+1); + } + return a; + } + x(0); + )")) == 75), + "Fonctions mutuellement récursives", + true + ); + return 0; } \ No newline at end of file