ropensci / charlatan

Create fake data in R

Home Page:https://docs.ropensci.org/charlatan/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Person providers ensure no leading or trailing whitespace

kylevoyto opened this issue · comments

A good test for the ch_name function would be ensure there's no leading or trailing whitespace.

res <- ch_name(100, locale = loc)
expect_equal(nchar(trimws(res)), nchar(res))

Leading or trailing whitespace can be indicative of an issue generating the name. For example, in the format "{{first_names}} {{last_names}}" the last_names variable might return a blank for some reason or another. The returned name might be "Selim ". Current automated testing will likely overlook the issue.

I can spot many trailing spaces in names after running ch_name(100, locale = "fa_IR"), such as "محمدرضا علی پور ". I can also spot trailing spaces in some names lists:

Thanks @kylevoyto

I think we should just fix the cases where we've left trailing or leading white space in name lists, like the example you providved.

Good idea to add tests for this.

the last_names variable might return a blank for some reason or another

Not sure why that is. 🤔

Regarding the mention of the {{last_names}} format. I was thinking of an instance where the available variable might be misspelled, such as last_nams, so the name will not be properly rendered. Anyway, just thought I'd clarify if anyone else reads this at some point.

thanks for this @kylevoyto - on vacation now, will respond mid next week