Sha256: ebcc6684a4c74ee05b63c515491fd419563f24bf8452de7a208f6373dafc39fc

Contents?: true

Size: 647 Bytes

Versions: 38

Compression:

Stored size: 647 Bytes

Contents

source('./pascals-triangle.R')
library(testthat)

test_that("zero rows", {
  expect_equal(pascalsTriangle(0), list())
})

test_that("single row", {
  expect_equal(pascalsTriangle(1), list(1))
})

test_that("two rows", {
  expect_equal(pascalsTriangle(2), list(1, c(1, 1)))
})

test_that("three rows", {
  expect_equal(pascalsTriangle(3), list(1, c(1, 1), c(1, 2, 1)))
})

test_that("four rows", {
  expect_equal(pascalsTriangle(4), list(1, c(1, 1), c(1, 2, 1), c(1, 3, 3, 1)))
})

test_that("negative rows", {
  expect_error(pascalsTriangle(-1))
})

test_that("null/no rows", {
  expect_error(pascalsTriangle(NULL))
})

print("All tests passed!")

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
trackler-2.1.0.19 tracks/r/exercises/pascals-triangle/test_pascals-triangle.R
trackler-2.1.0.18 tracks/r/exercises/pascals-triangle/test_pascals-triangle.R
trackler-2.1.0.17 tracks/r/exercises/pascals-triangle/test_pascals-triangle.R
trackler-2.1.0.16 tracks/r/exercises/pascals-triangle/test_pascals-triangle.R
trackler-2.1.0.15 tracks/r/exercises/pascals-triangle/test_pascals-triangle.R
trackler-2.1.0.14 tracks/r/exercises/pascals-triangle/test_pascals-triangle.R
trackler-2.1.0.13 tracks/r/exercises/pascals-triangle/test_pascals-triangle.R
trackler-2.1.0.12 tracks/r/exercises/pascals-triangle/test_pascals-triangle.R
trackler-2.1.0.11 tracks/r/exercises/pascals-triangle/test_pascals-triangle.R
trackler-2.1.0.10 tracks/r/exercises/pascals-triangle/test_pascals-triangle.R
trackler-2.1.0.9 tracks/r/exercises/pascals-triangle/test_pascals-triangle.R
trackler-2.1.0.8 tracks/r/exercises/pascals-triangle/test_pascals-triangle.R
trackler-2.1.0.7 tracks/r/exercises/pascals-triangle/test_pascals-triangle.R
trackler-2.1.0.6 tracks/r/exercises/pascals-triangle/test_pascals-triangle.R
trackler-2.1.0.5 tracks/r/exercises/pascals-triangle/test_pascals-triangle.R
trackler-2.1.0.4 tracks/r/exercises/pascals-triangle/test_pascals-triangle.R
trackler-2.1.0.3 tracks/r/exercises/pascals-triangle/test_pascals-triangle.R
trackler-2.1.0.2 tracks/r/exercises/pascals-triangle/test_pascals-triangle.R
trackler-2.1.0.1 tracks/r/exercises/pascals-triangle/test_pascals-triangle.R
trackler-2.1.0.0 tracks/r/exercises/pascals-triangle/test_pascals-triangle.R