ferencd@0: #ifndef TESTS_H ferencd@0: #define TESTS_H ferencd@0: ferencd@0: #define UNUSED(x) (void)x; ferencd@0: ferencd@0: #include "nap_runtime.h" ferencd@0: #include "utils.h" ferencd@0: ferencd@0: /* ferencd@0: * Macros for making the life of the test writer easier ferencd@0: */ ferencd@0: ferencd@0: #define SCRIPT_START \ ferencd@0: nap_runtime* runtime = nap_runtime_create(0); \ ferencd@0: ASSERT_FALSE(runtime == NULL); \ ferencd@0: int found_indicator = 0; \ ferencd@0: nap_bytecode_chunk* bytecode = nap_runtime_compile(runtime, ferencd@0: ferencd@0: #define SCRIPT_END \ ferencd@0: ,0); \ ferencd@0: ASSERT_FALSE(bytecode == NULL); \ ferencd@0: int t = nap_runtime_execute(runtime, bytecode); \ ferencd@0: ASSERT_EQ(1, t); ferencd@0: ferencd@0: #define VAR_INT(a) nap_runtime_get_int(runtime, #a, &found_indicator) ferencd@0: ferencd@0: #define VAR_REAL(a) nap_runtime_get_real(runtime, #a, &found_indicator) ferencd@0: ferencd@0: #define VAR_BYTE(a) nap_runtime_get_byte(runtime, #a, &found_indicator) ferencd@0: ferencd@0: #define VAR_STRING(a) nap_runtime_get_string(runtime, #a, &found_indicator) ferencd@0: ferencd@0: #define SCRIPT_SHUTDOWN \ ferencd@0: nap_runtime_shutdown(&runtime); \ ferencd@0: ASSERT_TRUE(runtime == NULL); ferencd@0: ferencd@0: ferencd@0: #ifdef _WINDOWS ferencd@0: #pragma warning(disable: 4127) ferencd@0: #endif ferencd@0: ferencd@0: #define SCRIPT_ASSERT_STREQ(with,what) \ ferencd@0: do { \ ferencd@0: char* what = VAR_STRING(what); \ ferencd@0: ASSERT_STREQ(with, what); \ ferencd@0: free(what); \ ferencd@0: } while(0); ferencd@0: ferencd@0: #endif // TESTS_H