1NAME <- "limit"
2source(file.path('_helper', 'init.R'))
3
4# - Simple limit ---------------------------------------------------------------
5
6A <- B <- letters[1:5]
7B[2] <- "B"
8B[6] <- "F"
9# diffChr(A, B)
10all.equal(as.character(diffChr(A, B, line.limit=2)), rdsf(100))
11all.equal(as.character(diffChr(A, B, line.limit=3)), rdsf(200))
12
13# - More Extensive Limits ------------------------------------------------------
14
15Puromycin2 <- Puromycin
16set.seed(1)
17Puromycin2$conc[c(8, 15:19, 22)] <- round(runif(7), 2)
18Puromycin2$state[17] <- "treated"
19
20all.equal(
21  as.character(
22    diffPrint(Puromycin, Puromycin2, line.limit=15, mode="sidebyside")
23  ),
24  rdsf(300)
25)
26
27# # Not working right
28# diffPrint(Puromycin, Puromycin2, line.limit=15, mode="context")
29all.equal(
30  as.character(
31    diffPrint(Puromycin, Puromycin2, line.limit=15, mode="unified")
32  ),
33  rdsf(500)
34)
35
36all.equal(
37  as.character(
38    diffPrint(Puromycin, Puromycin2, line.limit=5, mode="sidebyside")
39  ),
40  rdsf(600)
41)
42all.equal(
43  as.character(
44    diffPrint(Puromycin, Puromycin2, line.limit=5, mode="context")
45  ),
46  rdsf(700)
47)
48all.equal(
49  as.character(
50    diffPrint(Puromycin, Puromycin2, line.limit=5, mode="unified")
51  ),
52  rdsf(800)
53)
54
55Puromycin3 <- Puromycin2
56names(Puromycin3)[3L] <- "blargh"
57all.equal(
58  as.character(
59    diffPrint(Puromycin, Puromycin3, line.limit=7, mode="sidebyside")
60  ),
61  rdsf(900)
62)
63all.equal(
64  as.character(
65    diffPrint(Puromycin, Puromycin3, line.limit=6, mode="context")
66  ),
67  rdsf(1000)
68)
69# - Dual limit values ----------------------------------------------------------
70
71A <- letters[1:10]
72B <- LETTERS[1:10]
73all.equal(
74  as.character(diffChr(A, B, line.limit=c(10, 3))), rdsf(1100)
75)
76all.equal(
77  as.character(diffChr(A, B, line.limit=c(13, 3))), rdsf(1200)
78)
79try(diffChr(A, B, line.limit=c(3, 13))) # "larger than or"
80
81# - Cause errors ---------------------------------------------------------------
82
83try(diffChr(letters, LETTERS, line.limit=1:3)) # "vector of length"
84
85# - Vanishing header -----------------------------------------------------------
86
87# issue 64
88all.equal(
89  as.character(
90    diffChr(
91      letters, letters[-13], context=auto_context(0, 10), line.limit=1L,
92      pager="off"
93  ) ),
94  rdsf(1300)
95)
96
97