浏览代码

Add test for zero length matches

pull/21/head
父节点
当前提交
fa92157c36
共有 1 个文件被更改,包括 7 次插入 和 0 次删除
  1. +7
    -0
      tests/testthat/test-regex.R

+ 7
- 0
tests/testthat/test-regex.R 查看文件

@@ -20,6 +20,13 @@ test_that("start/end indices are integers", {
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", {
m <- regex(c("abcaba", "aba", "z"), c("(a)(b)(d)?c?"), global = FALSE)
expect_equal(max_match_index(m), c(4, 3, NA_integer_))

正在加载...
取消
保存