Sha256: 0f2c105096828fee822a53ce53c4dff5fb6a7e81bd34190975ffa42bffd86702

Contents?: true

Size: 1.33 KB

Versions: 26

Compression:

Stored size: 1.33 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.")
})

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

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
trackler-2.1.0.48 tracks/r/exercises/rotational-cipher/test_rotational-cipher.R
trackler-2.1.0.47 tracks/r/exercises/rotational-cipher/test_rotational-cipher.R
trackler-2.1.0.46 tracks/r/exercises/rotational-cipher/test_rotational-cipher.R
trackler-2.1.0.45 tracks/r/exercises/rotational-cipher/test_rotational-cipher.R
trackler-2.1.0.44 tracks/r/exercises/rotational-cipher/test_rotational-cipher.R
trackler-2.1.0.43 tracks/r/exercises/rotational-cipher/test_rotational-cipher.R
trackler-2.1.0.42 tracks/r/exercises/rotational-cipher/test_rotational-cipher.R
trackler-2.1.0.41 tracks/r/exercises/rotational-cipher/test_rotational-cipher.R
trackler-2.1.0.40 tracks/r/exercises/rotational-cipher/test_rotational-cipher.R
trackler-2.1.0.39 tracks/r/exercises/rotational-cipher/test_rotational-cipher.R
trackler-2.1.0.38 tracks/r/exercises/rotational-cipher/test_rotational-cipher.R
trackler-2.1.0.37 tracks/r/exercises/rotational-cipher/test_rotational-cipher.R
trackler-2.1.0.36 tracks/r/exercises/rotational-cipher/test_rotational-cipher.R
trackler-2.1.0.34 tracks/r/exercises/rotational-cipher/test_rotational-cipher.R
trackler-2.1.0.33 tracks/r/exercises/rotational-cipher/test_rotational-cipher.R
trackler-2.1.0.32 tracks/r/exercises/rotational-cipher/test_rotational-cipher.R
trackler-2.1.0.31 tracks/r/exercises/rotational-cipher/test_rotational-cipher.R
trackler-2.1.0.30 tracks/r/exercises/rotational-cipher/test_rotational-cipher.R
trackler-2.1.0.29 tracks/r/exercises/rotational-cipher/test_rotational-cipher.R
trackler-2.1.0.28 tracks/r/exercises/rotational-cipher/test_rotational-cipher.R