Skip to content

Commit 26f36d1

Browse files
authored
Merge pull request #5 from mrDrivingDuck/master
Add testing shell
2 parents d916860 + 955ae2a commit 26f36d1

File tree

12 files changed

+388
-382
lines changed

12 files changed

+388
-382
lines changed

test/Assert.R

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#
2+
#
3+
# @Author -- Jingtang Zhang
4+
# @Date -- 2018.8.18, Ningbo
5+
# @Update -- 2018.8.19, Ningbo
6+
#
7+
#
8+
9+
# Config IP address and port who is running DolphinDB server
10+
ip_addr <- "192.168.137.132"
11+
port <- 8888
12+
13+
# Count all cases, print error message
14+
assert <- function(record, item, target, current) {
15+
16+
if (TRUE == all.equal(target, current)) {
17+
record[1] <- record[1] + 1L
18+
} else {
19+
print(paste("ITEM:", item, "FAILED"))
20+
}
21+
record[2] <- record[2] + 1L
22+
return (record)
23+
}
24+
25+
# Print testing result
26+
printer <- function(record) {
27+
msg <- paste("Build Failed:", as.character(record[2]-record[1]), "/", as.character(record[2]))
28+
print(msg, quote = FALSE)
29+
}

test/TestAnyVector.R

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,29 @@
22
#
33
# @Author -- Jingtang Zhang
44
# @Date -- 2018.8.1, Hangzhou
5-
# @Update -- 2018.8.17, Hangzhou
5+
# @Update -- 2018.8.19, Ningbo
66
#
77
#
88

9+
source("Assert.R")
10+
911
library("RDolphinDB")
10-
conn <- dbConnect(DolphinDB(), "192.168.137.132", 8888)
12+
conn <- dbConnect(DolphinDB(), ip_addr, port)
1113
if (conn@connected == TRUE) {
1214

13-
ptm <- proc.time()
14-
result <- dbRun(conn, "(1, table(2018.07.22 2018.08.21 as date, `Hello`World as str),5.5, 1 2 3, 2012.06M)")
15-
print(result)
16-
print(class(result))
17-
print(proc.time() - ptm)
15+
record <- c(0L, 0L)
1816

17+
result <- dbRun(conn, "(1, table(2018.07.22 2018.08.21 as date, `Hello`World as str), 5.5, 1 2 3, 2012.06M)")
18+
value_int <- 1L
19+
value_table <- data.frame(
20+
date = as.Date(c("2018-07-22", "2018-08-21")),
21+
str = as.character(c("Hello", "World"))
22+
)
23+
value_dbl <- 5.5
24+
value_vec <- c(1L, 2L, 3L)
25+
value_month <- as.Date("2012-06-01")
26+
record <- assert(record, "test anyvector", result, list(value_int, value_table, value_dbl, value_vec, value_month))
27+
28+
printer(record)
1929
}
2030
dbClose(conn)

test/TestDataFrame.R

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,35 @@
22
#
33
# @Author -- Jingtang Zhang
44
# @Date -- 2018.7.31, Hangzhou
5-
# @Update -- 2018.8.15, Hangzhou
5+
# @Update -- 2018.8.19, Ningbo
66
#
77
#
88

9+
source("Assert.R")
10+
911
library("RDolphinDB")
10-
conn <- dbConnect(DolphinDB(), "192.168.137.132", 8888)
12+
conn <- dbConnect(DolphinDB(), ip_addr, port)
1113
if (conn@connected == TRUE) {
1214

13-
ptm <- proc.time()
15+
record <- c(0L, 0L)
16+
1417
table <- data.frame(id=c(1,2,3), value=c(2.5, 3.5, 5.5))
1518
clm <- 1L
1619
row <- 1L
1720
testList <- list(table, clm, row)
1821
result <- dbRpc(conn, "cell", testList)
19-
print(result)
20-
print(class(result))
21-
print(proc.time() - ptm)
22+
record <- assert(record, "test dataframe rpc", result, 3.5)
2223

23-
ptm <- proc.time()
2424
result <- dbRun(conn, "table(2018.06.12 2018.07.22 2018.08.21 as date, 1 2 NULL as int, `x`dd`zz as str, 10.8 7.6 3.5 as dbl)")
25-
print(result)
26-
print(class(result))
27-
print(proc.time() - ptm)
25+
table <- data.frame(
26+
date=as.Date(c("2018-06-12","2018-07-22","2018-08-21")),
27+
int=c(1L, 2L, NA),
28+
str=c("x", "dd", "zz"),
29+
dbl=c(10.8, 7.6, 3.5)
30+
)
31+
record <- assert(record, "test dataframe run", result, table)
32+
33+
printer(record)
2834

2935
}
3036
dbClose(conn)

0 commit comments

Comments
 (0)