File: test_range.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 (36 lines) | stat: -rw-r--r-- 987 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
34
35
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"))