Sha256: 7fe8f580f1435458a817d1c8ae044fb525f13a6b09c43fd8fdc85bebc7843ee2

Contents?: true

Size: 1.34 KB

Versions: 140

Compression:

Stored size: 1.34 KB

Contents

source("./rotational-cipher.R")
library(testthat)

test_that("rotate a by 1", {
  text <- "a"
  key <- 1
  expect_equal(rotate(text, key), "b")
})

test_that("rotate a by 26, same output as input", {
  text <- "a"
  key <- 26
  expect_equal(rotate(text, key), "a")
})

test_that("rotate a by 0, same output as input", {
  text <- "a"
  key <- 0
  expect_equal(rotate(text, key), "a")
})

test_that("rotate m by 13", {
  text <- "m"
  key <- 13
  expect_equal(rotate(text, key), "z")
})

test_that("rotate n by 13 with wrap around alphabet", {
  text <- "n"
  key <- 13
  expect_equal(rotate(text, key), "a")
})

test_that("rotate capital letters", {
  text <- "OMG"
  key <- 5
  expect_equal(rotate(text, key), "TRL")
})

test_that("rotate spaces", {
  text <- "O M G"
  key <- 5
  expect_equal(rotate(text, key), "T R L")
})

test_that("rotate numbers", {
  text <- "Testing 1 2 3 testing"
  key <- 4
  expect_equal(rotate(text, key), "Xiwxmrk 1 2 3 xiwxmrk")
})

test_that("rotate punctuation", {
  text <- "Let's eat, Grandma!"
  key <- 21
  expect_equal(rotate(text, key), "Gzo'n zvo, Bmviyhv!")
})

test_that("rotate all letters", {
  text <- "The quick brown fox jumps over the lazy dog."
  key <- 13
  expect_equal(rotate(text, key), 
               "Gur dhvpx oebja sbk whzcf bire gur ynml qbt.")
})

message("All tests passed for exercise: rotational-cipher")

Version data entries

140 entries across 140 versions & 1 rubygems

Version Path
trackler-2.2.1.126 tracks/r/exercises/rotational-cipher/test_rotational-cipher.R
trackler-2.2.1.125 tracks/r/exercises/rotational-cipher/test_rotational-cipher.R
trackler-2.2.1.124 tracks/r/exercises/rotational-cipher/test_rotational-cipher.R
trackler-2.2.1.123 tracks/r/exercises/rotational-cipher/test_rotational-cipher.R
trackler-2.2.1.122 tracks/r/exercises/rotational-cipher/test_rotational-cipher.R
trackler-2.2.1.121 tracks/r/exercises/rotational-cipher/test_rotational-cipher.R
trackler-2.2.1.120 tracks/r/exercises/rotational-cipher/test_rotational-cipher.R
trackler-2.2.1.119 tracks/r/exercises/rotational-cipher/test_rotational-cipher.R
trackler-2.2.1.118 tracks/r/exercises/rotational-cipher/test_rotational-cipher.R
trackler-2.2.1.117 tracks/r/exercises/rotational-cipher/test_rotational-cipher.R
trackler-2.2.1.116 tracks/r/exercises/rotational-cipher/test_rotational-cipher.R
trackler-2.2.1.115 tracks/r/exercises/rotational-cipher/test_rotational-cipher.R
trackler-2.2.1.114 tracks/r/exercises/rotational-cipher/test_rotational-cipher.R
trackler-2.2.1.113 tracks/r/exercises/rotational-cipher/test_rotational-cipher.R
trackler-2.2.1.111 tracks/r/exercises/rotational-cipher/test_rotational-cipher.R
trackler-2.2.1.110 tracks/r/exercises/rotational-cipher/test_rotational-cipher.R
trackler-2.2.1.109 tracks/r/exercises/rotational-cipher/test_rotational-cipher.R
trackler-2.2.1.108 tracks/r/exercises/rotational-cipher/test_rotational-cipher.R
trackler-2.2.1.107 tracks/r/exercises/rotational-cipher/test_rotational-cipher.R
trackler-2.2.1.106 tracks/r/exercises/rotational-cipher/test_rotational-cipher.R