Gating network behind compile flag
This commit is contained in:
+3
-1
@@ -7,7 +7,9 @@ add_subdirectory(animation)
|
||||
add_subdirectory(assert)
|
||||
add_subdirectory(asset)
|
||||
add_subdirectory(error)
|
||||
add_subdirectory(network)
|
||||
if(DUSK_NETWORKING)
|
||||
add_subdirectory(network)
|
||||
endif()
|
||||
add_subdirectory(thread)
|
||||
add_subdirectory(display)
|
||||
add_subdirectory(entity)
|
||||
|
||||
@@ -9,6 +9,8 @@ dusktest(test_modulerequire.c)
|
||||
|
||||
dusktest(test_scriptdef.c)
|
||||
|
||||
dusktest(test_moduleconsole.c)
|
||||
|
||||
dusktest(test_overworldscene.c)
|
||||
target_compile_definitions(test_overworldscene PRIVATE
|
||||
DUSK_ASSETS_DIR="${DUSK_ASSETS_DIR}"
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
/**
|
||||
* Copyright (c) 2026 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#include "dusktest.h"
|
||||
#include "console/console.h"
|
||||
#include "script/scriptmanager.h"
|
||||
#include "util/memory.h"
|
||||
|
||||
static int console_setup(void **state) {
|
||||
consoleInit();
|
||||
|
||||
errorret_t ret = scriptManagerInit();
|
||||
if(errorIsNotOk(ret)) { errorCatch(ret); return -1; }
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int console_teardown(void **state) {
|
||||
errorret_t ret = scriptManagerDispose();
|
||||
if(errorIsNotOk(ret)) errorCatch(ret);
|
||||
|
||||
consoleDispose();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void test_console_print_joins_stringified_args(void **state) {
|
||||
jerry_value_t result;
|
||||
errorret_t ret = scriptManagerExec(
|
||||
"Console.print('hello', 42, true);", &result
|
||||
);
|
||||
assert_true(errorIsOk(ret));
|
||||
jerry_value_free(result);
|
||||
|
||||
assert_string_equal(
|
||||
CONSOLE.line[CONSOLE_HISTORY_MAX - 1], "hello 42 true"
|
||||
);
|
||||
|
||||
assert_int_equal(memoryGetAllocatedCount(), 0);
|
||||
}
|
||||
|
||||
static void test_console_print_no_args_prints_empty_line(void **state) {
|
||||
jerry_value_t result;
|
||||
errorret_t ret = scriptManagerExec("Console.print();", &result);
|
||||
assert_true(errorIsOk(ret));
|
||||
jerry_value_free(result);
|
||||
|
||||
assert_string_equal(CONSOLE.line[CONSOLE_HISTORY_MAX - 1], "");
|
||||
|
||||
assert_int_equal(memoryGetAllocatedCount(), 0);
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
assertInit();
|
||||
const struct CMUnitTest tests[] = {
|
||||
cmocka_unit_test_setup_teardown(
|
||||
test_console_print_joins_stringified_args,
|
||||
console_setup, console_teardown
|
||||
),
|
||||
cmocka_unit_test_setup_teardown(
|
||||
test_console_print_no_args_prints_empty_line,
|
||||
console_setup, console_teardown
|
||||
),
|
||||
};
|
||||
return cmocka_run_group_tests(tests, NULL, NULL);
|
||||
}
|
||||
Reference in New Issue
Block a user