Skip to content

Commit

Permalink
Merge pull request #16 from 0x6flab/11-23-fix_tests_with_more_than_on…
Browse files Browse the repository at this point in the history
…e_-_

fix: tests with more than one `-`
  • Loading branch information
rodneyosodo committed Nov 23, 2023
2 parents a598159 + 82171f4 commit 6ab25a4
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions generator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,16 +165,18 @@ func test(t *testing.T, name, prefix, suffix string, firstNames, secondNames []s
}
name = strings.TrimSuffix(name, suffix)

if strings.Contains(name, "-") {
if !strings.Contains(name, "-") {
t.Errorf("Expected a name does not contain a family name separator, got %s", name)
}

if strings.Count(name, "-") == 1 {
if !contains(firstNames, strings.Split(name, "-")[0]) {
t.Errorf("Generated name '%s' is not contained in the list of first names", name)
}

if !contains(secondNames, strings.Split(name, "-")[1]) {
t.Errorf("Generated name '%s' is not contained in the list of second names", name)
}
} else {
t.Errorf("Expected a name does not contain a family name separator, got %s", name)
}
}

Expand Down

0 comments on commit 6ab25a4

Please sign in to comment.