Sha256: 938883d047021c4e67780ed8abf42586f7bdc69ec93c660b825163a98c0ccba9

Contents?: true

Size: 684 Bytes

Versions: 26

Compression:

Stored size: 684 Bytes

Contents

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

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

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

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

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

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

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

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

print("All tests passed for exercise: pascals-triangle")

Version data entries

26 entries across 26 versions & 1 rubygems

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