diff options
| author | Daniel Gavin <danielgavin5@hotmail.com> | 2021-12-07 16:39:50 +0100 |
|---|---|---|
| committer | Daniel Gavin <danielgavin5@hotmail.com> | 2021-12-07 16:39:50 +0100 |
| commit | ca0bc6739213a2ef38aa79efc53b20793b00e1a1 (patch) | |
| tree | 0ccef266ef6effad14bd866052abecd4631322ad /src/testing/testing.odin | |
| parent | b37fc717c7ecc9a62e052c94a373fddde66352ad (diff) | |
More tests
Diffstat (limited to 'src/testing/testing.odin')
| -rw-r--r-- | src/testing/testing.odin | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/testing/testing.odin b/src/testing/testing.odin index 4720497..d02695c 100644 --- a/src/testing/testing.odin +++ b/src/testing/testing.odin @@ -211,3 +211,33 @@ expect_hover :: proc(t: ^testing.T, src: ^Source, expect_hover_string: string) { } } + +expect_definition_locations :: proc(t: ^testing.T, src: ^Source, expect_locations: []common.Location) { + setup(src); + + locations, ok := server.get_definition_location(src.document, src.position); + + if !ok { + testing.error(t, "Failed get_definition_location"); + } + + if len(expect_locations) == 0 && len(locations) > 0 { + testing.errorf(t, "Expected empty locations, but received %v", locations); + } + + flags := make([]int, len(expect_locations)); + + for expect_location, i in expect_locations { + for location, j in locations { + if location == expect_location { + flags[i] += 1; + } + } + } + + for flag, i in flags { + if flag != 1 { + testing.errorf(t, "Expected location %v, but received %v", expect_locations[i], locations); + } + } +}
\ No newline at end of file |