From 70818f746ce29a429c4bd2302abc0a026ee1e93d Mon Sep 17 00:00:00 2001 From: Brad Lewis <22850972+BradLewis@users.noreply.github.com> Date: Thu, 16 Oct 2025 06:05:26 -0400 Subject: Fix issue calculating the absolute range with a file starting with a new line --- tests/common_test.odin | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 tests/common_test.odin (limited to 'tests') diff --git a/tests/common_test.odin b/tests/common_test.odin new file mode 100644 index 0000000..3fb64de --- /dev/null +++ b/tests/common_test.odin @@ -0,0 +1,36 @@ +package tests + +import "core:log" +import "src:common" +import "core:testing" + +@(test) +common_get_absolute_range_starting_newline :: proc(t: ^testing.T) { + src := ` + package foo + + main :: proc() { + + } + ` + + range := common.Range{ + start = { + line = 0, + character = 0, + }, + end = { + line = 1, + character = 0, + } + } + + absolute_range, ok := common.get_absolute_range(range, transmute([]u8)(src)) + if !ok { + log.error(t, "failed to get absolute_range") + } + + if absolute_range != {0, 1} { + log.error(t, "incorrect absolute_range", absolute_range, ok) + } +} -- cgit v1.2.3