Newer
Older
test_that("node_to_object works for simple r2ogs6 classes", {
prj_path <- (system.file("extdata/benchmarks/flow_free_expansion",
"flow_free_expansion.prj", package = "r2ogs6"))
ogs6_obj <- OGS6$new(sim_name = "sim",
read_in(ogs6_obj, prj_path, "/OpenGeoSysProject/parameters/parameter")
expect_equal(length(ogs6_obj$parameters), 7)
expect_equal(ogs6_obj$parameters[[1]]$name, "E")
expect_equal(ogs6_obj$parameters[[1]]$type, "Constant")
expect_equal(ogs6_obj$parameters[[1]]$value, 10e9)
test_that("node_to_object works for nodes that have both attributes and text", {
vtu_path <- system.file("extdata/benchmarks/flow_free_expansion",
"cube_1x1x1.vtu",
package = "r2ogs6")
test_node <- xml2::read_xml("<test a = \"1\">some text</test>")
test_obj <- node_to_object(test_node,
expect_equal(length(test_obj), 2)
expect_equal(test_obj[["a"]], "1")
expect_equal(test_obj[["xml_text"]], "some text")
})
test_that("node_to_object works for simple lists", {
Ruben Heinrich
committed
my_xml <- xml2::read_xml("<a><b>1</b><b>2</b></a>")
my_node <- xml2::xml_find_first(my_xml, "/a")
Ruben Heinrich
committed
expect_equal(my_list, list(b = "1", b = "2"))
Ruben Heinrich
committed
test_that("order_parameters works for classes with Ellipsis argument", {
ogs6_parameter <- prj_parameter(name = "test",
Ruben Heinrich
committed
type = "test",
index_values = list("1", "1 2"))
parameters <- list(type = "test",
index_values = list("1", "1 2"),
name = "test")
class_name <- "prj_parameter"
Ruben Heinrich
committed
ordered_parameters <- order_parameters(parameters,
class_name)
expect_equal(ordered_parameters, list(name = "test",
type = "test",
index_values = list("1", "1 2")))
})