This commit is contained in:
2026-05-10 08:47:32 -04:00
parent d6bee8b2e2
commit 7c645a43ac
2 changed files with 16 additions and 24 deletions

View File

@@ -1,7 +1,7 @@
main :: () {
print("\nBeginning tests...\n");
//test_get_visible_lines();
//test_handle_arrow_empty_lines();
test_get_visible_lines();
test_handle_arrow_empty_lines();
test_handle_arrow_one_line();
print("Tests completed successfully\n");
}
@@ -11,7 +11,7 @@ test_get_visible_lines :: () {
state.line_height = 10;
state.window_height = 100;
assert_test(get_visible_lines(state).count == 0);
line: [..]u8;
array_add(*line, array_view("foo"));
array_add(*state.lines, line);
@@ -26,7 +26,7 @@ test_handle_arrow_empty_lines :: () {
codes := Input.Key_Code.[.ARROW_DOWN, .ARROW_UP, .ARROW_LEFT, .ARROW_RIGHT];
for codes {
handle_arrow(*state, .{key_code=it});
handle_arrow(*state, .{key_code=it});
assert(state.cursor_x == 0 && state.cursor_y == 0, "%: cursor_x % & cursor_y %", it, state.cursor_x, state.cursor_y);
}
@@ -40,7 +40,7 @@ test_handle_arrow_one_line :: () {
state.cursor_x = 0;
state.line_height = 10;
state.window_height = 100;
add_line(*state, "foo bar");
codes := Input.Key_Code.[.ARROW_DOWN, .ARROW_UP, .ARROW_LEFT];
@@ -49,18 +49,15 @@ test_handle_arrow_one_line :: () {
assert(state.cursor_x == 0 && state.cursor_y == 0);
}
print("lines: %\n", state.lines);
print("visible_lines: %\n", get_visible_lines(state));
handle_arrow(*state, .ARROW_RIGHT);
assert_test(state.cursor_x == 1 && state.cursor_y == 0);
assert_test(state.cursor_x == 1 && state.cursor_y == 0);
print("test_handle_arrow_one_line completed successfully\n");
}
assert_test :: (value: bool, $call := #caller_code, loc := #caller_location) {
if value == true return;
assert(false, "%\nValue is false.", #run get_expression(call), value, loc = loc);
assert(false, "%\nValue is false.", #run get_expression(call), value, loc = loc);
}
get_expression :: (call := #caller_code) -> string {