File: test_memory.R

package info (click to toggle)
r-cran-urltools 1.7.3%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 516 kB
  • sloc: cpp: 1,234; ansic: 303; sh: 13; makefile: 2
file content (30 lines) | stat: -rw-r--r-- 831 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
context("Avoid regressions around proxy objects")

test_that("Values are correctly disposed from memory",{
  memfn <- function(d = NULL){
    test_url <- "https://test.com"
    if(!is.null(d)){
      test_url <- urltools::param_set(test_url, "q" , urltools::url_encode(d))
     }
    return(test_url)
  }
  
  baseurl <- "https://test.com"
  expect_equal(memfn(), baseurl)
  expect_equal(memfn("blah"), paste0(baseurl, "?q=blah"))
  expect_equal(memfn(), baseurl)
})

test_that("Parameters correctly add to output",{
  outfn <- function(d = FALSE){
    test_url <- "https://test.com"
    if(d){
      test_url <- urltools::param_set(test_url, "q", urltools::url_encode(d))
    }
    return(test_url)
  }
  
  baseurl <- "https://test.com"
  expect_equal(outfn(), baseurl)
  expect_equal(outfn(TRUE), paste0(baseurl, "?q=TRUE"))
})