mllg / checkmate

Fast and versatile argument checks
https://mllg.github.io/checkmate/
Other
261 stars 30 forks source link

checkChoice / assertChoice messages with large set of choices #266

Open antalk2 opened 3 weeks ago

antalk2 commented 3 weeks ago

The output of

x="a"; checkmate::assertChoice( x, paste0(LETTERS, 1:1000  ))

is both long and truncated in a way that the closing of the set and the value of x (}, but is 'a'.) is not shown.

The following patch modifies set_collapse() to limit its result to 80 characters by replacing the middle part with "...". (Added the .txt extension to make github to accept the attachment)

0001-set_collapse-witdh-80L.patch.txt

The following patch (to be applied on top of the above) removes the dependency on stringr. Includes a modified copy of stringr::str_trunc() (using nchar() and substr())

0002-include-modified-copy-of-stringr-str_trunc.patch.txt