summaryrefslogtreecommitdiffstats
path: root/tests/python/test_custom_validators.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/python/test_custom_validators.py')
-rw-r--r--tests/python/test_custom_validators.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/python/test_custom_validators.py b/tests/python/test_custom_validators.py
new file mode 100644
index 0000000..c7fe1bd
--- /dev/null
+++ b/tests/python/test_custom_validators.py
@@ -0,0 +1,33 @@
+# Copyright (c) Microsoft Corporation. All rights reserved.
+# Licensed under the MIT License.
+
+import pytest
+
+import lsprotocol.types as lsp
+import lsprotocol.validators as v
+
+
+@pytest.mark.parametrize(
+ "number", [v.INTEGER_MIN_VALUE, v.INTEGER_MAX_VALUE, 0, 1, -1, 1000, -1000]
+)
+def test_integer_validator_basic(number):
+ lsp.VersionedTextDocumentIdentifier(version=number, uri="")
+
+
+@pytest.mark.parametrize("number", [v.INTEGER_MIN_VALUE - 1, v.INTEGER_MAX_VALUE + 1])
+def test_integer_validator_out_of_range(number):
+ with pytest.raises(Exception):
+ lsp.VersionedTextDocumentIdentifier(version=number, uri="")
+
+
+@pytest.mark.parametrize(
+ "number", [v.UINTEGER_MIN_VALUE, v.UINTEGER_MAX_VALUE, 0, 1, 1000, 10000]
+)
+def test_uinteger_validator_basic(number):
+ lsp.Position(line=number, character=0)
+
+
+@pytest.mark.parametrize("number", [v.UINTEGER_MIN_VALUE - 1, v.UINTEGER_MAX_VALUE + 1])
+def test_uinteger_validator_out_of_range(number):
+ with pytest.raises(Exception):
+ lsp.Position(line=number, character=0)