Skip to content

Commit 09e257d

Browse files
committed
fixed failing test with date value. Added basic test for matrix analysis
1 parent 81b4136 commit 09e257d

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

tests/variables-t.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ namespace testing {
8383
session->execScript("ctd <- as.POSIXct(\\\"2016-05-04 11:11:11 GMT\\\")");
8484
json djson = watcher.toJson("ctd");
8585
ASSERT_EQ(djson["class"], "POSIXct");
86-
ASSERT_EQ(djson["value"], 1462385471);
86+
long val = djson["value"];
87+
ASSERT_EQ(1462374671, val);
8788
//function
8889
session->execScript("hlp <- help");
8990
json funjson = watcher.toJson("hlp");
@@ -131,6 +132,17 @@ namespace testing {
131132
ASSERT_EQ(df["rows"][14][1], 164.0);
132133
}
133134

135+
TEST_F(VarTest, matrixTest) {
136+
EnvironmentWatcher watcher(Rcpp::Environment::global_env(), session->getExecCallback());
137+
session->execScript("mat <- matrix(data=1:8, nrow=4, ncol=2, dimnames=list(c(\\\"x\\\",\\\"y\\\",\\\"z\\\",\\\"a\\\"), c(\\\"foo\\\",\\\"bar\\\")))");
138+
json mat = watcher.toJson("mat");
139+
cerr << "val = " << mat.dump(4) << endl;
140+
int numrows = mat["nrow"];
141+
ASSERT_EQ(numrows, 4);
142+
int numcols = mat["ncol"];
143+
ASSERT_EQ(numcols, 2);
144+
}
145+
134146
TEST_F(VarTest, simpleDelta) {
135147
EnvironmentWatcher watcher(Rcpp::Environment::global_env(), session->getExecCallback());
136148
session->execScript("x <- 2; y <- 4");

0 commit comments

Comments
 (0)