Commit 44acf048 authored by Dorchies David's avatar Dorchies David
Browse files

test: add test on get_result

Refs #9
No related merge requests found
Pipeline #54275 failed with stage
in 10 minutes and 56 seconds
Showing with 20 additions and 2 deletions
+20 -2
......@@ -32,6 +32,8 @@ get_result <- function(cfg,
fun_format = NULL,
m = read_bin_result_matrix(cfg, scenario, variant)) {
file <- attr(m, "file")
df_col <- get_result_tree(cfg, scenario, variant)
filters <- paste(filters, collapse = " AND ")
if (filters != "") {
......@@ -78,8 +80,9 @@ get_result <- function(cfg,
class(m) <- c("SicResult", class(m))
if (!is.null(fun_format)) {
return(fun_format(m))
m <- fun_format(m)
}
attr(m, "file") <- file
return(m)
}
......@@ -123,7 +126,9 @@ read_bin_result_matrix <- function(cfg, scenario, variant = 0) {
endian = "little")
readBin(con, "raw", n = 4) # @todo check end file content
close(con)
return(matrix(data, ncol = dims[2], byrow = TRUE))
m <- matrix(data, ncol = dims[2], byrow = TRUE)
attr(m, "file") <- file
return(m)
}
......
......@@ -27,3 +27,16 @@ test_that("get_result with tidy return a tidy result", {
expect_equal(attr(result, "t"), seq(0, 86400, by = 60))
expect_type(result$bf, "integer")
})
test_that("flow in first section must be equal to injected flow", {
t <- seq(0, 86400, by = 600)
dfTest <- data.frame(t = t,
v = 100 * sin((seq_along(t) - 1) * pi / 16) + 200)
input <- SicInput(dfTest, locations = SicLocation(list(Nd = 1, Pr = 1, Car = "Q")))
sic_run_unsteady(cfg, iniParams = c(1, 0, 0, 1, 1), sicInputs = input, params = list(DT = "600"))
result <- get_result(cfg, 1, 1,
filters = c("bf=1", "sn=1", "var='Q'"),
fun_format = compact_tidy_result)
expect_equal(result$values[1][[1]], dfTest$v)
})
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment