Skip to content

Commit 4d6ffb7

Browse files
committed
Add ValueError tests for nighit (PR 1377)
PR #1377 adds guardrails to nighit(). This PR add tests to those guardrails. Signed-off-by: Arthit Suriyawongkul <arthit@gmail.com>
1 parent 3a99c24 commit 4d6ffb7

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

tests/core/test_morpheme.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,26 @@
1010
class MorphemeTestCase(unittest.TestCase):
1111
def test_nighit(self):
1212
self.assertEqual(nighit("สํ", "คีต"), "สังคีต")
13+
self.assertEqual(
14+
nighit("สํ", "คีต "), "สังคีต"
15+
) # w2 has trailing space, should still work
16+
self.assertEqual(
17+
nighit("สํ ", "คีต"), "สังคีต"
18+
) # w1 has trailing space, should still work
1319
self.assertEqual(nighit("สํ", "จร"), "สัญจร")
1420
self.assertEqual(nighit("สํ", "ฐาน"), "สัณฐาน")
1521
self.assertEqual(nighit("สํ", "นิษฐาน"), "สันนิษฐาน")
1622
self.assertEqual(nighit("สํ", "ปทา"), "สัมปทา")
1723
self.assertEqual(nighit("สํ", "โยค"), "สังโยค")
24+
self.assertEqual(nighit("", "คีต"), "คีต") # w1 is empty, should return w2
25+
self.assertEqual(nighit("สํ", ""), "สํ") # w2 is empty, should return w1
26+
1827
with self.assertRaises(NotImplementedError):
1928
nighit("abc", "คีต") # w1 does not end with ํ and len > 2
2029
with self.assertRaises(NotImplementedError):
2130
nighit("สํ", "มาร") # consonant ม is not in any supported group
31+
with self.assertRaises(ValueError):
32+
nighit("สํ", "123") # w2 does not contain any Thai consonant
2233

2334
def test_is_native_thai(self):
2435
self.assertFalse(is_native_thai(None)) # type: ignore[arg-type]

0 commit comments

Comments
 (0)