File: test_custom_validators.py

package info (click to toggle)
lsprotocol 2025.0.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,408 kB
  • sloc: python: 7,567; cs: 1,225; sh: 15; makefile: 4
file content (33 lines) | stat: -rw-r--r-- 1,049 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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)