From db2c5bade042a6901fb4dd2a9239e8bacc885564 Mon Sep 17 00:00:00 2001
From: Dorchies David <david.dorchies@irstea.fr>
Date: Thu, 17 Mar 2022 10:04:40 +0100
Subject: [PATCH] fix: check errors

---
 DESCRIPTION                                    | 4 +++-
 NAMESPACE                                      | 1 -
 R/convert_sic_params.R                         | 3 ++-
 R/create_section_txt.R                         | 2 +-
 R/get_result.R                                 | 1 -
 man/convert_sic_params.Rd                      | 3 ++-
 man/create_section_txt.Rd                      | 2 +-
 tests/testthat/test-create_uniform_reach_txt.R | 9 ++++++---
 8 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/DESCRIPTION b/DESCRIPTION
index ad61b48..11207c5 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -20,5 +20,7 @@ RoxygenNote: 7.1.2
 Roxygen: list(markdown = TRUE)
 Imports: 
     logger,
+    magrittr,
     terra,
-    tidyquery
+    tidyquery,
+    xml2
diff --git a/NAMESPACE b/NAMESPACE
index 61371cb..ad1a24b 100644
--- a/NAMESPACE
+++ b/NAMESPACE
@@ -20,4 +20,3 @@ export(sic_run_fortran)
 export(split_reach)
 import(magrittr)
 import(xml2)
-importFrom(rlang,parse_expr)
diff --git a/R/convert_sic_params.R b/R/convert_sic_params.R
index 7b674e6..a3a4f37 100644
--- a/R/convert_sic_params.R
+++ b/R/convert_sic_params.R
@@ -11,7 +11,8 @@
 #' @export
 #'
 #' @examples
-#' convert_sic_params(list(SCE = 1, VAR = 1))
+#' cfg <- cfg_tmp_project()
+#' convert_sic_params(list(SCE = 1, VAR = 1), cfg = cfg)
 #'
 convert_sic_params <- function(params, cfg = loadConfig()) {
   if (!"INTERF" %in% names(params)) {
diff --git a/R/create_section_txt.R b/R/create_section_txt.R
index 8f38a25..ed7e759 100644
--- a/R/create_section_txt.R
+++ b/R/create_section_txt.R
@@ -10,7 +10,7 @@
 #' @export
 #' @examples
 #' # Trapezoidal section
-#' export_section_txt("Trapeze", 0, "T", list(B = 2, S = 1.5, ZF = 100, ZB = 102))
+#' create_section_txt("Trapeze", 0, "T", list(B = 2, S = 1.5, ZF = 100, ZB = 102))
 create_section_txt <- function(section_name, abscissa, section_type, profile, distance_majeur = FALSE) {
 
   if (section_type == "T") {
diff --git a/R/get_result.R b/R/get_result.R
index aa91ab5..b2a4197 100644
--- a/R/get_result.R
+++ b/R/get_result.R
@@ -6,7 +6,6 @@
 #'
 #' @return
 #' @export
-#' @importFrom rlang parse_expr
 #' @import magrittr
 #'
 #' @examples
diff --git a/man/convert_sic_params.Rd b/man/convert_sic_params.Rd
index 83537b4..76bd523 100644
--- a/man/convert_sic_params.Rd
+++ b/man/convert_sic_params.Rd
@@ -21,6 +21,7 @@ This function is called by \link{sic_run_fortran} to convert list of parameters
 The parameter \code{INTERF} is set to 0 (zero) by default.
 }
 \examples{
-convert_sic_params(list(SCE = 1, VAR = 1))
+cfg <- cfg_tmp_project()
+convert_sic_params(list(SCE = 1, VAR = 1), cfg = cfg)
 
 }
diff --git a/man/create_section_txt.Rd b/man/create_section_txt.Rd
index cd02ce1..eecc674 100644
--- a/man/create_section_txt.Rd
+++ b/man/create_section_txt.Rd
@@ -31,5 +31,5 @@ Export a section in importation SIC format
 }
 \examples{
 # Trapezoidal section
-export_section_txt("Trapeze", 0, "T", list(B = 2, S = 1.5, ZF = 100, ZB = 102))
+create_section_txt("Trapeze", 0, "T", list(B = 2, S = 1.5, ZF = 100, ZB = 102))
 }
diff --git a/tests/testthat/test-create_uniform_reach_txt.R b/tests/testthat/test-create_uniform_reach_txt.R
index c6eaa34..62a8c12 100644
--- a/tests/testthat/test-create_uniform_reach_txt.R
+++ b/tests/testthat/test-create_uniform_reach_txt.R
@@ -6,15 +6,18 @@ profT <- list(
 )
 
 test_that("Trapezoidal minor section", {
+  profT2 <- profT
+  profT2$ZF <- 99
+  profT2$ZB <- 101
   expect_equal(
     create_uniform_reach_txt(abscissas = c(1000, 2000),
                              upstream_bed_elevation = 100,
                              slope = 0.001,
                              section_type = "T",
-                             profile = profT),
+                             profile = profT)[1:2],
     list(
-      "00001000" = c("Section x=1000 $ 1000 $  $ 0 $ T", "2\t1", "102\t100"),
-      "00002000" = c("Section x=2000 $ 2000 $  $ 0 $ T", "2\t1", "101\t99")
+      "00001000" = create_section_txt("Section x=1000", 1000, "T", profT),
+      "00002000" = create_section_txt("Section x=2000", 2000, "T", profT2)
     )
   )
 })
-- 
GitLab