Skip to content

Commit e10cbe3

Browse files
committed
add acceptance test for formatting
1 parent 740ed2e commit e10cbe3

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

tests/testthat/test-format.R

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
context("format")
2+
3+
expect_format_equal <- function(formatted, result) {
4+
expect_equal(
5+
paste(formatted, collapse = "\n"),
6+
paste(result, collapse = "\n")
7+
)
8+
}
9+
10+
test_that("unequal sizes", {
11+
x <- blob(raw(2 ** 2), raw(2 ** 11), raw(2 ** 20))
12+
13+
expect_format_equal(
14+
format(x),
15+
c(
16+
"blob[4 B]",
17+
"blob[2,050 B]",
18+
"blob[1,050,000 B]"
19+
)
20+
)
21+
22+
expect_format_equal(
23+
format(x, trim = FALSE),
24+
c(
25+
"blob[ 4 B]",
26+
"blob[ 2,050 B]",
27+
"blob[1,050,000 B]"
28+
)
29+
)
30+
})
31+
32+
test_that("similar sizes", {
33+
x <- blob(raw(2 ** 10), raw(2 ** 11), raw(2 ** 12))
34+
35+
expect_format_equal(
36+
format(x),
37+
c(
38+
"blob[1 kb]",
39+
"blob[2 kb]",
40+
"blob[4 kb]"
41+
)
42+
)
43+
})

0 commit comments

Comments
 (0)