diff options
Diffstat (limited to 'src/testing')
| -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 |