Skip to content

Commit a2e97ed

Browse files
committed
add tests for raw string search
1 parent 879cde4 commit a2e97ed

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

tests/testthat/test-search.R

+13
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,13 @@ test_that("enclosed_by_quotes works as expected", {
55
expect_false(enclosed("hello_world", 4))
66
expect_true(enclosed("'hello_world", 4))
77
expect_true(enclosed("\"hello_world", 4))
8+
expect_true(enclosed("R\"(hello_world", 4))
9+
expect_true(enclosed("r\"(hello_world", 4))
10+
expect_true(enclosed("R\"-(hello_world", 5))
11+
expect_true(enclosed("r\"-(hello_world", 5))
812
expect_true(enclosed("\"\\\"hello_world", 4))
913
expect_false(enclosed("\"a\"hello_world", 4))
14+
expect_false(enclosed("R\"(a)\"hello_world", 7))
1015
expect_true(enclosed("'\\'hello_world", 4))
1116
expect_false(enclosed("'a'hello_world", 4))
1217
})
@@ -32,6 +37,14 @@ test_that("find_unbalanced_bracket works as expected", {
3237
expect_equal(bsearch("foo(\"xyz(bar", 0, 10)[[1]], c(0, 3))
3338
expect_equal(bsearch("foo('xyz', bar", 0, 10)[[1]], c(0, 3))
3439
expect_equal(bsearch("foo(\"xyz\", bar", 0, 10)[[1]], c(0, 3))
40+
expect_equal(bsearch("foo(R\"(x\"yz)\", bar", 0, 15)[[1]], c(0, 3))
41+
expect_equal(bsearch("foo(r\"(x\"yz)\", bar", 0, 15)[[1]], c(0, 3))
42+
expect_equal(bsearch("foo(R\"(x\"yz)\", bar", 0, 15)[[1]], c(0, 3))
43+
expect_equal(bsearch("foo(r\"(x\"yz)\", bar", 0, 15)[[1]], c(0, 3))
44+
expect_equal(bsearch("foo(\"(x\"yz)\", bar", 0, 15)[[1]], c(-1, -1))
45+
expect_equal(bsearch("foo(\"(x\"yz)\", bar", 0, 15)[[1]], c(-1, -1))
46+
expect_equal(bsearch("foo(\"(x\"yz)\", bar", 0, 15)[[1]], c(-1, -1))
47+
expect_equal(bsearch("foo(\"(x\"yz)\", bar", 0, 15)[[1]], c(-1, -1))
3548
expect_equal(bsearch("𐐀𐐀𐐀(𐐀𐐀𐐀", 0, 5)[[1]], c(0, 3))
3649

3750
# multiline

0 commit comments

Comments
 (0)