1library(pystr) 2context("pystr_isnumeric") 3 4test_that("it returns true when all characters are numeric", { 5 expect_true(pystr_isnumeric("123")) 6}) 7 8test_that("it returns false when not all characters are numeric", { 9 expect_false(pystr_isnumeric("12a3")) 10}) 11 12test_that("it works with a vector of strings", { 13 nums = c("123", "123a", "123!") 14 expect_equal(pystr_isnumeric(nums), c(TRUE, FALSE, FALSE)) 15}) 16 17test_that("it works with NAs", { 18 nums = c("123", "123a", NA) 19 expect_equal(pystr_isnumeric(nums), c(TRUE, FALSE, NA)) 20}) 21