File: test-url.R

package info (click to toggle)
r-cran-shiny 1.10.0%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 10,948 kB
  • sloc: javascript: 39,934; sh: 28; makefile: 20
file content (42 lines) | stat: -rw-r--r-- 1,083 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
test_that("Query string parsing", {
  expect_identical(
    parseQueryString("?foo=1&bar=b+a%20r&b+a%20z=baz&=nokey&novalue=&=&noequal&end=end"),
    list(
      foo     = '1',
      bar     = 'b a r',
      `b a z` = 'baz',
                'nokey',
      novalue = '',
                '',
      noequal = '',
      end     = 'end'
    )
  )

  # Should be the same with or without leading question mark
  expect_identical(parseQueryString("?foo=1&bar=b"), parseQueryString("foo=1&bar=b"))

  # Leading/trailing/consecutive ampersands are ignored
  expect_identical(parseQueryString("?&a=1&&b=2&"), parseQueryString("?a=1&b=2"))

  # Nested and non-nested query strings
  expect_identical(
    parseQueryString("a[i1][j1]=x&b[i1][j1]=y&b[i2][j1]=z"),
    list(
      "a[i1][j1]" = "x",
      "b[i1][j1]" = "y",
      "b[i2][j1]" = "z"
    )
  )

  expect_identical(
    parseQueryString("a[i1][j1]=x&b[i1][j1]=y&b[i2][j1]=z", nested = TRUE),
    list(
      a = list(i1 = list(j1 = "x")),
      b = list(
        i1 = list(j1 = "y"),
        i2 = list(j1 = "z")
      )
    )
  )
})