tests/testthat/test-day21.R

context("test-day21.R")

test_that("matrix enhancement", {
  rules <- c(
    "../.# => ##./#../...",
    ".#./..#/### => #..#/..../..../#..#")

  rules <- rules %>%
    lapply(expand_rule) %>%
    unlist()

  seed <- ".#./..#/###" %>%
    string_to_matrix()

  step1 <- enhance_matrix(seed, rules)

  step1 %>%
    matrix_to_string() %>%
    expect_equal("#..#/..../..../#..#")

  step2 <- enhance_matrix(step1, rules)
  step2 %>%
    matrix_to_string() %>%
    expect_equal("##.##./#..#../....../##.##./#..#../......")
})
tjmahr/adventofcode17 documentation built on May 30, 2019, 2:29 p.m.