@@ -97,6 +97,14 @@ def test_collate(self):
9797 collate (["ไก่" , "เป็ด" , "หมู" , "วัว" ], reverse = True ),
9898 ["หมู" , "วัว" , "เป็ด" , "ไก่" ],
9999 )
100+ # Edge cases: mixed Thai and numbers
101+ self .assertEqual (collate (["ก" , "1" , "ข" ]), ["1" , "ก" , "ข" ])
102+ # Edge cases: with spaces (spaces sort before letters)
103+ result = collate ([" ก" , "ก" , " ก" ])
104+ self .assertEqual (len (result ), 3 )
105+ self .assertIn (" ก" , result )
106+ self .assertIn ("ก" , result )
107+ self .assertIn (" ก" , result )
100108
101109 # ### pythainlp.util.numtoword
102110
@@ -720,6 +728,11 @@ def test_emoji_to_thai(self):
720728 ":ธง_ไทย: นี่คือธงประเทศไทย" ,
721729 )
722730
731+ # Edge cases
732+ self .assertEqual (emoji_to_thai ("" ), "" ) # empty string
733+ self .assertEqual (emoji_to_thai ("no emoji" ), "no emoji" ) # no emoji
734+ self .assertEqual (emoji_to_thai ("ไม่มีอีโมจิ" ), "ไม่มีอีโมจิ" ) # Thai no emoji
735+
723736 def test_sound_syllable (self ):
724737 test = [
725738 ("มา" , "live" ),
@@ -863,6 +876,10 @@ def test_syllable_open_close_detector(self):
863876
864877 def test_to_idna (self ):
865878 self .assertEqual (to_idna ("คนละครึ่ง.com" ), "xn--42caj4e6bk1f5b1j.com" )
879+ # Additional test cases for IDNA encoding
880+ self .assertEqual (to_idna ("ไทย.com" ), "xn--o3cw4h.com" )
881+ self .assertEqual (to_idna ("example.com" ), "example.com" ) # ASCII unchanged
882+ self .assertEqual (to_idna ("ภาษาไทย.th" ), "xn--o3crh0a8bb0k.th" )
866883
867884 def test_thai_strptime (self ):
868885 self .assertIsNotNone (
@@ -923,6 +940,11 @@ def test_tis620_to_utf8(self):
923940 self .assertEqual (
924941 tis620_to_utf8 ("¡ÃзÃÇ§ÍØµÊÒË¡ÃÃÁ" ), "กระทรวงอุตสาหกรรม"
925942 )
943+ # Additional test cases
944+ self .assertEqual (tis620_to_utf8 ("»ÃÐà·Èä·Â" ), "ประเทศไทย" )
945+ self .assertEqual (tis620_to_utf8 ("ÀÒÉÒä·Â" ), "ภาษาไทย" )
946+ # Empty string
947+ self .assertEqual (tis620_to_utf8 ("" ), "" )
926948
927949 def test_remove_repeat_consonants (self ):
928950 # update of pythainlp.copus.thai_words() able to break this
@@ -988,11 +1010,20 @@ def test_longest_common_subsequence(self):
9881010 self .assertEqual (longest_common_subsequence ("ABCBDAB" , "BDCAB" ), "BDAB" )
9891011 self .assertEqual (longest_common_subsequence ("AGGTAB" , "GXTXAYB" ), "GTAB" )
9901012 self .assertEqual (longest_common_subsequence ("ABCDGH" , "AEDFHR" ), "ADH" )
1013+
1014+ # Edge cases
1015+ self .assertEqual (longest_common_subsequence ("" , "" ), "" ) # empty strings
1016+ self .assertEqual (longest_common_subsequence ("ABC" , "" ), "" ) # one empty
1017+ self .assertEqual (longest_common_subsequence ("" , "ABC" ), "" ) # other empty
1018+ self .assertEqual (longest_common_subsequence ("A" , "A" ), "A" ) # single char match
1019+ self .assertEqual (longest_common_subsequence ("A" , "B" ), "" ) # single char no match
1020+ self .assertEqual (longest_common_subsequence ("ABC" , "ABC" ), "ABC" ) # identical
1021+ self .assertEqual (longest_common_subsequence ("ABC" , "XYZ" ), "" ) # no common chars
9911022 self .assertEqual (longest_common_subsequence ("ABC" , "AC" ), "AC" )
992- self . assertEqual ( longest_common_subsequence ( "ABC" , "DEF" ), "" )
993- self . assertEqual ( longest_common_subsequence ( "" , "ABC" ), "" )
994- self .assertEqual (longest_common_subsequence ("ABC " , "" ), "" )
995- self .assertEqual (longest_common_subsequence ("" , "" ), "" )
1023+
1024+ # Thai text
1025+ self .assertEqual (longest_common_subsequence ("ไทย " , "ไทย " ), "ไทย " )
1026+ self .assertEqual (longest_common_subsequence ("ภาษาไทย " , "ไทย " ), "ไทย " )
9961027
9971028 def test_analyze_thai_text (self ):
9981029 self .assertEqual (
0 commit comments