Coverage for tests/test_identifier.py: 100%

1# pylint: disable=W0621,C0116,C0114

2 import pytest

3 from castep_linter.fortran.identifier import Identifier

4

5

6 def test_identifier_equals():

7 assert Identifier("x") == Identifier("x")

8 assert Identifier("X") == Identifier("x")

9 assert Identifier("x") == Identifier("X")

10 assert Identifier("X") == Identifier("X")

11

12

13 def test_identifier_not_equals():

14 assert Identifier("x") != Identifier("y")

15 assert Identifier("X") != Identifier("y")

16 assert Identifier("x") != Identifier("Y")

17 assert Identifier("X") != Identifier("Y")

18

19

20 def test_string_equals():

21 assert Identifier("x") == "x"

22 assert Identifier("X") == "x"

23 assert Identifier("x") == "X"

24 assert Identifier("X") == "X"

25

26

27 def test_string_not_equals():

28 assert Identifier("x") != "y"

29 assert Identifier("X") != "y"

30 assert Identifier("x") != "Y"

31 assert Identifier("X") != "Y"

32

33 def test_identifier_hash_eq():

34 assert hash(Identifier("x")) == hash(Identifier("x"))

35 assert hash(Identifier("X")) == hash(Identifier("x"))

36 assert hash(Identifier("x")) == hash(Identifier("X"))

37 assert hash(Identifier("X")) == hash(Identifier("X"))

38

39 def test_identifier_hash_not_equals():

40 assert hash(Identifier("x")) != hash(Identifier("y"))

41 assert hash(Identifier("X")) != hash(Identifier("y"))

42 assert hash(Identifier("x")) != hash(Identifier("Y"))

43 assert hash(Identifier("X")) != hash(Identifier("Y"))

44

45

46 def test_identifier_compare_none():

47 assert Identifier("x") != None

48 assert Identifier("X") != None

49 assert None != Identifier("x")

50 assert None != Identifier("X")

51

52 def test_identifier_compare_object():

53 with pytest.raises(TypeError):

54 assert Identifier("x") != object()