Skip to content

Commit 8d5c17f

Browse files
derek73claude
andcommitted
test: cover nickname, comma+suffix, and single-token middle in fold
Addresses remaining review suggestions: nickname stripping happens in pre_process() before the fold and should compose correctly; the comma-delimited suffix form exercises a different code path than the no-comma title/suffix case; single-token names should leave middle empty too, not just last, for consistency with the other no-op test. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
1 parent daa2394 commit 8d5c17f

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

tests/test_middle_name_as_last.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,22 @@ def test_title_and_suffix_preserved(self) -> None:
4646
self.m(n.last, "Ahmad Hassan", n)
4747
self.m(n.suffix, "Jr", n)
4848

49+
def test_suffix_preserved_comma_format(self) -> None:
50+
# Comma-delimited suffix takes a different code path than the
51+
# title/suffix no-comma case above; the fold must still apply.
52+
n = self.hn("Hassan, Mohamad Ahmad Ali, Jr.")
53+
self.m(n.first, "Mohamad", n)
54+
self.m(n.middle, "", n)
55+
self.m(n.last, "Ahmad Ali Hassan", n)
56+
self.m(n.suffix, "Jr.", n)
57+
58+
def test_nickname_preserved(self) -> None:
59+
# Nicknames are stripped in pre_process(), before the fold runs.
60+
n = self.hn('Mohamad "Mo" Ahmad Ali Hassan')
61+
self.m(n.nickname, "Mo", n)
62+
self.m(n.middle, "", n)
63+
self.m(n.last, "Ahmad Ali Hassan", n)
64+
4965
def test_no_middle_is_noop(self) -> None:
5066
n = self.hn("John Doe")
5167
self.m(n.first, "John", n)
@@ -55,6 +71,7 @@ def test_no_middle_is_noop(self) -> None:
5571
def test_single_token_is_noop(self) -> None:
5672
n = self.hn("Cher")
5773
self.m(n.first, "Cher", n)
74+
self.m(n.middle, "", n)
5875
self.m(n.last, "", n)
5976

6077
def test_given_names_and_surnames_track_fold(self) -> None:

0 commit comments

Comments
 (0)