Skip to content

Commit

Permalink
Merge branch 'main' into bahadzie/issue7
Browse files Browse the repository at this point in the history
  • Loading branch information
bahadzie authored Apr 5, 2024
2 parents 1f12784 + 853ea41 commit 4a034e3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,23 @@ These examples illustrate the current functionality.
``` r
# numberize a French string
numberize("zéro", lang = "fr")
#> [1] 0
#> zéro
#> 0

# numberize a Spanish string
numberize("Siete mil quinientos cuarenta y cinco", lang = "es")
#> [1] 7545
#> Siete mil quinientos cuarenta y cinco
#> 7545

# numberize the English string "nine hundred and ninety-nine trillion, nine hundred and ninety-nine billion, nine hundred and ninety-nine million, nine hundred and ninety-nine thousand, nine hundred and ninety-nine" # nolint: line_length_linter.
formatC(numberize("nine hundred and ninety-nine trillion, nine hundred and ninety-nine billion, nine hundred and ninety-nine million, nine hundred and ninety-nine thousand, nine hundred and ninety-nine"), big.mark = ",", format = "fg") # nolint: line_length_linter.
#> [1] "999,999,999,999,999"
#> nine hundred and ninety-nine trillion, nine hundred and ninety-nine billion, nine hundred and ninety-nine million, nine hundred and ninety-nine thousand, nine hundred and ninety-nine
#> "999,999,999,999,999"

# some edge cases
numberize("veintiún", lang = "es")
#> [1] 21
#> veintiún
#> 21
numberize("veintiuno", lang = "es")
#> [1] 21

Expand Down
7 changes: 5 additions & 2 deletions tests/testthat/test-numberize.R
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,6 @@ test_that("french text with leading and trailing whitespace works", {
expect_identical(res, 1515)
})



test_that("text with non digit word returns NA", {
res <- numberize("epiverse", lang = "en")
expect_true(is.na(res))
Expand All @@ -102,3 +100,8 @@ test_that("text with whitespace at the start and end and tab and newline in betw
and thirty ", lang = "en")
expect_identical(unname(res), 130)
})

test_that("non digit word returns NA", {
res <- numberize("epiverse", lang = "en")
expect_true(is.na(res))
})

0 comments on commit 4a034e3

Please sign in to comment.