Sha256: fdafe4e93b9f100f596c572c1cddbbe6df9789e78cf8439691e9ff66cfe17b90

Contents?: true

Size: 686 Bytes

Versions: 140

Compression:

Stored size: 686 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))
})

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

Version data entries

140 entries across 140 versions & 1 rubygems

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