/** * Copyright (c) 2026 Dominic Masters * * This software is released under the MIT License. * https://opensource.org/licenses/MIT */ #include "dusktest.h" #include "script/scriptmanager.h" #include "script/module/modulebase.h" static int platform_setup(void **state) { errorret_t ret = scriptManagerInit(); if(errorIsNotOk(ret)) { errorCatch(ret); return -1; } return 0; } static int platform_teardown(void **state) { errorret_t ret = scriptManagerDispose(); if(errorIsNotOk(ret)) errorCatch(ret); return 0; } static void test_platform_current_matches_target_system(void **state) { jerry_value_t result; errorret_t ret = scriptManagerExec("Platform.current;", &result); assert_true(errorIsOk(ret)); assert_true(jerry_value_is_string(result)); char_t buf[32]; moduleBaseToString(result, buf, sizeof(buf)); assert_string_equal(buf, DUSK_TARGET_SYSTEM); jerry_value_free(result); } int main(void) { assertInit(); const struct CMUnitTest tests[] = { cmocka_unit_test_setup_teardown( test_platform_current_matches_target_system, platform_setup, platform_teardown ), }; return cmocka_run_group_tests(tests, NULL, NULL); }