2023-11-27 21:16:39 +01:00
|
|
|
#include "include/test.h"
|
|
|
|
|
2024-01-03 16:20:42 +01:00
|
|
|
#include "../src/include/execute.h"
|
|
|
|
#include "../src/include/utils.h"
|
2023-11-27 21:16:39 +01:00
|
|
|
|
|
|
|
int execute(string s) {
|
2024-01-03 16:20:42 +01:00
|
|
|
Memory memory;
|
|
|
|
return get<int>(execute(split_string(s, '\n'), memory));
|
2023-11-27 21:16:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
_TEST_PRESENTATION("Logique Booléenne");
|
|
|
|
|
|
|
|
_TEST_ASSERT(
|
|
|
|
_TEST_NO_EXCEPTION(execute("1 && 0;") == 0),
|
|
|
|
"Et",
|
|
|
|
true
|
|
|
|
);
|
|
|
|
|
|
|
|
_TEST_ASSERT(
|
|
|
|
_TEST_NO_EXCEPTION(execute("1 || 0;") == 1),
|
|
|
|
"Ou",
|
|
|
|
true
|
|
|
|
);
|
|
|
|
|
|
|
|
_TEST_ASSERT(
|
|
|
|
_TEST_NO_EXCEPTION(execute("!1;") == 0),
|
|
|
|
"Négation",
|
|
|
|
true
|
|
|
|
);
|
|
|
|
|
|
|
|
_TEST_ASSERT(
|
|
|
|
_TEST_NO_EXCEPTION(execute("2 == 2;") == 1),
|
|
|
|
"Égalité",
|
|
|
|
true
|
|
|
|
);
|
|
|
|
|
|
|
|
_TEST_ASSERT(
|
|
|
|
_TEST_NO_EXCEPTION(execute("2 != 2;") == 0),
|
|
|
|
"Différence",
|
|
|
|
true
|
|
|
|
);
|
|
|
|
|
|
|
|
_TEST_ASSERT(
|
|
|
|
_TEST_NO_EXCEPTION(execute("0 == 0 || 1;") == 1),
|
|
|
|
"Parenthésage",
|
|
|
|
true
|
|
|
|
);
|
|
|
|
|
|
|
|
_TEST_ASSERT(
|
|
|
|
_TEST_NO_EXCEPTION(execute("2 == 1 + 1;") == 1),
|
|
|
|
"Priorités",
|
|
|
|
true
|
|
|
|
);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|