Browse Source

Add test for zero length matches

pull/21/head
Garrick Aden-Buie 6 years ago
parent
commit
fa92157c36
1 changed files with 7 additions and 0 deletions
  1. +7
    -0
      tests/testthat/test-regex.R

+ 7
- 0
tests/testthat/test-regex.R View File

expect_is(m[[1]]$idx$group, "integer") expect_is(m[[1]]$idx$group, "integer")
}) })


test_that("length-zero match is NULL", {
m <- regex(c("other", "thing"), "thing|")
expect_null(m[[1]]$idx)
expect_equal(m[[2]]$idx$start, 1L)
expect_equal(m[[2]]$idx$end, 6L)
})

test_that("max_match_index works", { test_that("max_match_index works", {
m <- regex(c("abcaba", "aba", "z"), c("(a)(b)(d)?c?"), global = FALSE) m <- regex(c("abcaba", "aba", "z"), c("(a)(b)(d)?c?"), global = FALSE)
expect_equal(max_match_index(m), c(4, 3, NA_integer_)) expect_equal(max_match_index(m), c(4, 3, NA_integer_))

Loading…
Cancel
Save