summaryrefslogtreecommitdiffstats
path: root/tests/python/test_range.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-14 19:55:48 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-14 19:55:48 +0000
commit8be448d3881909fb0ce4b033cad71aa7575de0aa (patch)
treeda33caff06645347a08c3c9c56dd703e4acb5aa3 /tests/python/test_range.py
parentInitial commit. (diff)
downloadlsprotocol-8be448d3881909fb0ce4b033cad71aa7575de0aa.tar.xz
lsprotocol-8be448d3881909fb0ce4b033cad71aa7575de0aa.zip
Adding upstream version 2023.0.0.upstream/2023.0.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/python/test_range.py')
-rw-r--r--tests/python/test_range.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/python/test_range.py b/tests/python/test_range.py
new file mode 100644
index 0000000..9977e95
--- /dev/null
+++ b/tests/python/test_range.py
@@ -0,0 +1,36 @@
+# Copyright (c) Microsoft Corporation. All rights reserved.
+# Licensed under the MIT License.
+
+import hamcrest
+import pytest
+
+from lsprotocol import types as lsp
+
+
+@pytest.mark.parametrize(
+ ("a", "b", "expected"),
+ [
+ (
+ lsp.Range(lsp.Position(1, 23), lsp.Position(4, 56)),
+ lsp.Range(lsp.Position(1, 23), lsp.Position(4, 56)),
+ True,
+ ),
+ (
+ lsp.Range(lsp.Position(1, 23), lsp.Position(4, 56)),
+ lsp.Range(lsp.Position(1, 23), lsp.Position(4, 57)),
+ False,
+ ),
+ (
+ lsp.Range(lsp.Position(1, 23), lsp.Position(4, 56)),
+ lsp.Range(lsp.Position(1, 23), lsp.Position(7, 56)),
+ False,
+ ),
+ ],
+)
+def test_range_equality(a, b, expected):
+ hamcrest.assert_that(a == b, hamcrest.is_(expected))
+
+
+def test_range_repr():
+ a = lsp.Range(lsp.Position(1, 23), lsp.Position(4, 56))
+ hamcrest.assert_that(f"{a!r}", hamcrest.is_("1:23-4:56"))