You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: tests/testthat/test-format_text.R
+20Lines changed: 20 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,14 @@
1
1
test_that("text formatting helpers work as expected", {
2
+
expect_equal(
3
+
format_text(c("A very long First", "Some similar long Second", "Shorter Third", "More or less long Fourth", "And finally the Last"), width=20),
4
+
"A very long First,\nSome similar long\nSecond, Shorter\nThird, More or less\nlong Fourth and And\nfinally the Last\n"
5
+
)
6
+
7
+
expect_equal(
8
+
format_text(c("A very long First", "Some similar long Second", "Shorter Third", "More or less long Fourth", "And finally the Last"), last=" or ", enclose="`", width=20),
9
+
"`A very long\nFirst`, `Some\nsimilar long\nSecond`, `Shorter\nThird`, `More or\nless long Fourth`\nor `And finally the\nLast`\n"
10
+
)
11
+
2
12
expect_equal(
3
13
text_fullstop(c("something", "something else.")),
4
14
c("something.", "something else.")
@@ -15,6 +25,11 @@ test_that("text formatting helpers work as expected", {
15
25
"First, Second and Last"
16
26
)
17
27
28
+
expect_equal(
29
+
text_concatenate(c("First", "Second", "Last"), last=" or ", enclose="`"),
30
+
"`First`, `Second` or `Last`"
31
+
)
32
+
18
33
expect_equal(
19
34
text_remove(c("one!", "two", "three!"), "!"),
20
35
c("one", "two", "three")
@@ -27,4 +42,9 @@ test_that("text formatting helpers work as expected", {
0 commit comments