|
| 1 | +from pytest import raises |
| 2 | + |
1 | 3 | from machine.corpora import ScriptureRef
|
2 | 4 |
|
3 | 5 |
|
4 | 6 | def test_compare_to_strict():
|
5 | 7 | assert compare_to_strict("MAT 1:1", "MAT 1:2") == -1, "VerseLessThan"
|
6 | 8 | assert compare_to_strict("MAT 1:1", "MAT 1:1") == 0, "VerseEqualTo"
|
7 | 9 | assert compare_to_strict("MAT 1:2", "MAT 1:1") == 1, "VerseGreaterThan"
|
| 10 | + assert compare_to_strict("MAT 1:1-3", "MAT 1:1") == 1, "MultiVerseExtensionGreaterThan" |
| 11 | + assert compare_to_strict("MAT 1:1", "MAT 1:1-3") == -1, "MultiVerseExtensionLessThan" |
| 12 | + assert compare_to_strict("MAT 1:1-3", "MAT 1:2") == -1, "MultiVerseStartLessThan" |
| 13 | + assert compare_to_strict("MAT 1:2", "MAT 1:1-3") == 1, "MultiVerseEndGreaterThan" |
8 | 14 | assert compare_to_strict("MAT 1:0/1:p", "MAT 1:0/2:p") == -1, "NonVerseLessThan"
|
9 | 15 | assert compare_to_strict("MAT 1:0/1:p", "MAT 1:0/1:p") == 0, "NonVerseEqualTo"
|
10 | 16 | assert compare_to_strict("MAT 1:0/2:p", "MAT 1:0/1:p") == 1, "NonVerseGreaterThan"
|
11 | 17 | assert compare_to_strict("MAT 1:0/1:esb", "MAT 1:0/1:esb/1:p") == -1, "NonVerseParentChild"
|
| 18 | + assert compare_to_strict("MAT 1:0/2:esb", "MAT 1:0/1:esb/1:p") == 1, "NonVerseParentOtherChild" |
12 | 19 |
|
13 | 20 |
|
14 | 21 | def test_compare_to_relaxed():
|
15 | 22 | assert compare_to_relaxed("MAT 1:1", "MAT 1:2") == -1, "VerseLessThan"
|
16 | 23 | assert compare_to_relaxed("MAT 1:1", "MAT 1:1") == 0, "VerseEqualTo"
|
17 | 24 | assert compare_to_relaxed("MAT 1:2", "MAT 1:1") == 1, "VerseGreaterThan"
|
18 | 25 | assert compare_to_relaxed("MAT 1:0/1:p", "MAT 1:0/2:p") == 0, "NonVerseSameMarkerDifferentPosition"
|
19 |
| - assert compare_to_relaxed("MAT 1:0/2:esb", "MAT 1:0/1:esb/1:p") == -1, "NonVerseParentChild" |
| 26 | + assert compare_to_relaxed("MAT 1:0/1:esb", "MAT 1:0/1:esb/1:p") == -1, "NonVerseParentChild" |
| 27 | + assert compare_to_relaxed("MAT 1:0/2:esb", "MAT 1:0/1:esb/1:p") == -1, "NonVerseParentOtherChild" |
| 28 | + |
| 29 | + |
| 30 | +def test_is_equal_to(): |
| 31 | + ref1 = ScriptureRef.parse("MAT 1:1/1:p") |
| 32 | + ref1dup = ScriptureRef.parse("MAT 1:1/1:p") |
| 33 | + ref2 = ScriptureRef.parse("MAT 1:2/1:p") |
| 34 | + obj1 = "A different type" |
| 35 | + |
| 36 | + assert ref1 == ref1dup |
| 37 | + assert ref1 != ref2 |
| 38 | + assert ref1 != obj1 |
| 39 | + |
| 40 | + |
| 41 | +def test_is_equal_to_throws_argument_exception(): |
| 42 | + ref1 = ScriptureRef.parse("MAT 1:1/1:p") |
| 43 | + obj1 = "A different type" |
| 44 | + |
| 45 | + with raises(TypeError): |
| 46 | + ref1.compare_to(obj1) |
20 | 47 |
|
21 | 48 |
|
22 | 49 | def compare_to_strict(ref1_str, ref2_str):
|
|
0 commit comments