tests/testthat/test_clean_code.R

context("clean_code")
library(codebreaker)

test_that("cb_clean_code() cleans code", {

  expect_equal(codebreaker:::cb_clean_code("RBGY"), "RBGY")
  expect_equal(codebreaker:::cb_clean_code("BGYM"), "BGYM")

  expect_equal(codebreaker:::cb_clean_code("rbgy"), "RBGY")
  expect_equal(codebreaker:::cb_clean_code("bgym"), "BGYM")
  
  expect_equal(codebreaker:::cb_clean_code("RXXX"), "RXXX")
  expect_equal(codebreaker:::cb_clean_code("rxxx"), "RXXX")

  expect_equal(codebreaker:::cb_clean_code("RBGY "), "RBGY")
  expect_equal(codebreaker:::cb_clean_code(" RBGY"), "RBGY")
  expect_equal(codebreaker:::cb_clean_code("R B G Y"), "RBGY")
  expect_equal(codebreaker:::cb_clean_code("R.B.G.Y"), "RBGY")
  expect_equal(codebreaker:::cb_clean_code(" R B G Y "), "RBGY")
  
  expect_equal(codebreaker:::cb_clean_code(""), "XXXX")

})

Try the codebreaker package in your browser

Any scripts or data that you put into this service are public.

codebreaker documentation built on Feb. 16, 2023, 10:54 p.m.