Skip to content

Commit 4c78129

Browse files
possible tests
1 parent f2c7f32 commit 4c78129

File tree

1 file changed

+39
-6
lines changed

1 file changed

+39
-6
lines changed

inst/tests/tests.Rraw

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21276,13 +21276,46 @@ if (test_R.utils) local({
2127621276
})
2127721277

2127821278
# Create a data.table when one vector is transposed doesn't respect the name defined by user #4124
21279-
test(2321.1, DT <- data.table(a=1:2, b=matrix(1:2)), data.table(a=1:2, b=1:2))
21280-
test(2321.2, names(DT), names(data.frame(a=1:2, b=matrix(1:2))))
21281-
test(2321.3, DT <- data.table(a=integer(), b=matrix(1L, nrow=0L, ncol=1L)), data.table(a=integer(), b=integer()))
21282-
test(2321.4, names(DT), names(data.frame(a=integer(), b=matrix(1L, nrow=0L, ncol=1L))))
21279+
test(2321.01, DT <- data.table(a=1:2, b=matrix(1:2)), data.table(a=1:2, b=1:2))
21280+
test(2321.02, names(DT), names(data.frame(a=1:2, b=matrix(1:2))))
21281+
test(2321.03, DT <- data.table(a=integer(), b=matrix(1L, nrow=0L, ncol=1L)), data.table(a=integer(), b=integer()))
21282+
test(2321.04, names(DT), names(data.frame(a=integer(), b=matrix(1L, nrow=0L, ncol=1L))))
2128321283
## but respect named column vectors
21284-
test(2321.5, DT <- data.table(a=1:2, cbind(b=3:4)), data.table(a=1:2, b=3:4))
21285-
test(2321.6, names(DT), names(data.frame(a=1:2, cbind(b=3:4))))
21284+
test(2321.05, DT <- data.table(a=1:2, cbind(b=3:4)), data.table(a=1:2, b=3:4))
21285+
test(2321.06, names(DT), names(data.frame(a=1:2, cbind(b=3:4))))
21286+
## also respect old naming pattern when invoked indirectly, #7145
21287+
M = cbind(1:3)
21288+
test(2321.07, as.data.table(M), data.table(V1=1:3))
21289+
rownames(M) = c('a', 'b', 'c')
21290+
test(2321.08, as.data.table(M), data.table(V1=1:3))
21291+
test(2321.09, as.data.table(M, keep.rownames='id'), data.table(id=c('a', 'b', 'c'), V1=1:3))
21292+
colnames(M) = 'zz'
21293+
test(2321.10, as.data.table(M), data.table(zz=1:3))
21294+
test(2321.11, as.data.table(M, keep.rownames='id'), data.table(id=c('a', 'b', 'c'), zz=1:3))
21295+
colnames(M) = 'x'
21296+
test(2321.12, as.data.table(M), data.table(x=1:3))
21297+
test(2321.13, as.data.table(M, keep.rownames='id'), data.table(id=c('a', 'b', 'c'), x=1:3))
21298+
M = cbind(M, y=4:6)
21299+
test(2321.14, as.data.table(M), data.table(x=1:3, y=4:6))
21300+
test(2321.15, as.data.table(M, keep.rownames='id'), data.table(id=c('a', 'b', 'c'), x=1:3, y=4:6))
21301+
colnames(M) = c('A', 'B')
21302+
test(2321.16, as.data.table(M), data.table(A=1:3, B=4:6))
21303+
test(2321.17, as.data.table(M, keep.rownames='id'), data.table(id=c('a', 'b', 'c'), A=1:3, B=4:6))
21304+
colnames(M) = NULL
21305+
test(2321.18, as.data.table(M), data.table(V1=1:3, V2=4:6))
21306+
test(2321.19, as.data.table(M, keep.rownames='id'), data.table(id=c('a', 'b', 'c'), V1=1:3, V2=4:6))
21307+
colnames(M) = c('x', '')
21308+
test(2321.20, as.data.table(M), data.table(x=1:3, V2=4:6))
21309+
test(2321.21, as.data.table(M, keep.rownames='id'), data.table(id=c('a', 'b', 'c'), x=1:3, V2=4:6))
21310+
colnames(M) = c('', 'x')
21311+
test(2321.22, as.data.table(M), data.table(V1=1:3, x=4:6))
21312+
test(2321.23, as.data.table(M, keep.rownames='id'), data.table(id=c('a', 'b', 'c'), V1=1:3, x=4:6))
21313+
colnames(M) = c('', '')
21314+
test(2321.24, as.data.table(M), data.table(V1=1:3, V2=4:6))
21315+
test(2321.25, as.data.table(M, keep.rownames='id'), data.table(id=c('a', 'b', 'c'), V1=1:3, V2=4:6))
21316+
colnames(M) = c('A', '')
21317+
test(2321.26, as.data.table(M), data.table(A=1:3, V2=4:6))
21318+
test(2321.27, as.data.table(M, keep.rownames='id'), data.table(id=c('a', 'b', 'c'), A=1:3, V2=4:6))
2128621319

2128721320
# New fctr() helper: like factor() but retaining order by default #4837
2128821321
test(2322.01, levels(fctr(c("b","a","c"))), c("b","a","c"))

0 commit comments

Comments
 (0)