Skip to content

Commit 671b6e4

Browse files
committed
Some more unit tests (make sure we properly generate dimnames attribute if it doesn't exist)
1 parent 7c06c46 commit 671b6e4

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

inst/unitTests/cpp/Matrix.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,3 +211,8 @@ void runit_rownames_colnames_proxy(
211211
rownames(x) = row_names;
212212
colnames(x) = col_names;
213213
}
214+
215+
// [[Rcpp::export]]
216+
void runit_rownames_proxy(NumericMatrix x) {
217+
rownames(x) = CharacterVector::create("A", "B", "C");
218+
}

inst/unitTests/runit.Matrix.R

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,12 @@ if (.runThisTest) {
153153
checkEquals(colnames(m), LETTERS[1:2])
154154
checkException(runit_rownames_colnames_proxy(m, letters[1:3], letters[1:3]))
155155
checkException(runit_rownames_colnames_proxy(m, letters[1:2], NULL))
156-
}
156+
157+
m <- matrix(as.numeric(1:9), nrow = 3)
158+
runit_rownames_proxy(m)
159+
checkEquals(rownames(m), c("A", "B", "C"))
160+
checkEquals(colnames(m), NULL)
161+
}
157162

158163

159164
}

0 commit comments

Comments
 (0)