context("test-utils.R")
test_that("int_to_n_bits works", {
# Examples from Day 15 of AoC 2017
xs <- c(1092455, 430625591, 1181022009, 1233683848, 245556042, 1431495498,
1744312007, 137874439, 1352636452, 285222916)
bin_xs <- c(
"00000000000100001010101101100111", "00011001101010101101001100110111",
"01000110011001001111011100111001", "01001001100010001000010110001000",
"00001110101000101110001101001010", "01010101010100101110001101001010",
"01100111111110000001011011000111", "00001000001101111100110000000111",
"01010000100111111001100000100100", "00010001000000000010100000000100")
xs %>%
int_to_n_bits(32) %>%
expect_equal(bin_xs)
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.