Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
shikokuchuo committed Mar 5, 2024
1 parent 0020df9 commit 2b56ebe
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion tests/tests.R
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ test_equal(sha256("secret base"), "1951c1ca3d50e95e6ede2b1c26fefd0f0e8eba1e51a83
test_equal(sha256("secret base", convert = NA)[2L], 1592348733L)
test_equal(sha256(sha256("secret base", convert = FALSE)), "bd45eca9cbd4404cd467909fa8a2196ee9ffc7cb7f70f6343ff6647419744d41")
test_equal(sha256(data.frame(a = 1, b = 2)), "189874c3ac59edecb4eab95a2d7c1bbb293a6ccd04e3da5b28daca91ebc7f15b")
test_equal(sha256(c("secret", "base")), "6a38552b0dab8bf0a6c2f9a6a7acf764631319843f58e85f883301a3cd08b1f2")
test_equal(sha256(`attr<-`("base", "secret", "base")), "6e9e5b1a42304047ba73161360917d001c19974aebd98d345251ff138cddf6ea")
test_equal(sha256(`class<-`(sha256(character(), convert = FALSE), "hash")), "c762db048ff48f7ba3e9df5539db3aa678cb2f336d96d5c81b4e5d3e19783d14")
test_error(sha256(file = NULL), "'file' must be specified as a character string")
hash_func <- function(file, string) {
on.exit(unlink(file))
Expand All @@ -61,8 +64,12 @@ test_equal(sha256(NULL), "71557d1c8bac9bbe3cbec8d00bb223a2f372279827064095447e56
# xxHash64 tests:
test_equal(xxh64("secret base"), "ac1f7520cd9f49e9")
test_equal(xxh64("secret base", convert = NA)[1L], 544546732L)
test_that(xxh64("secret base", convert = FALSE), is.raw)
test_equal(xxh64(xxh64("secret base", convert = FALSE)), "f0d7a8c177d5a602")
test_equal(xxh64(data.frame(a = 1, b = 2)), "cbc8601c2c4a3c16")
test_equal(xxh64(c("secret", "base")), "c601d788544a7385")
test_equal(xxh64(`attr<-`("base", "secret", "base")), "801151a163c18252")
test_equal(xxh64(`class<-`(xxh64(character(), convert = FALSE), "hash")), "68ba986ecfccf4fc")
test_error(xxh64(file = NULL), "'file' must be specified as a character string")
xhash_func <- function(file, string) {
on.exit(unlink(file))
cat(string, file = file)
Expand Down

0 comments on commit 2b56ebe

Please sign in to comment.