Skip to content

Commit 0af4cd2

Browse files
aitapMichaelChirico
andcommitted
Expand test
Test assignment from a string as well as from a different factor. Co-Authored-By: Michael Chirico <[email protected]>
1 parent 2ba5cb5 commit 0af4cd2

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

inst/tests/tests.Rraw

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21114,6 +21114,10 @@ DF = structure(list(a = 1:2), class = c("data.frame", "no.reset"), row.names = c
2111421114
test(2310.01, as.data.table(DF), data.table(a=1:2))
2111521115

2111621116
# memrecycle() did not consider string encodings for factor levels #6886
21117-
DT = data.table(factor(rep(enc2utf8("\uf8"), 3)))
21118-
DT[1, V1 := iconv(levels(V1), from = "UTF-8", to = "latin1")]
21119-
test(2311, nlevels(DT$V1), 1L)
21117+
DT = data.table(factor(rep("\uf8", 3)))
21118+
# identical() to V1's only level but stored in a different CHARSXP
21119+
samelevel = iconv(levels(DT$V1), from = "UTF-8", to = "latin1")
21120+
DT[1, V1 := samelevel]
21121+
test(2311.1, nlevels(DT$V1), 1L) # used to be 2
21122+
DT[1, V1 := factor("a", levels = c("a", samelevel))]
21123+
test(2311.2, nlevels(DT$V1), 2L) # used to be 3

0 commit comments

Comments
 (0)