tests/testthat/test_meander_width.R

bankline_points <- fluvgeo::sin_bankline_points_sf

mw <- meander_width(bankline_points = bankline_points)

test_that("check meander_length output data structure", {
  expect_true(is.data.frame(mw))
  expect_true("loop" %in% colnames(mw))
  expect_true("bank_POINT_X" %in% colnames(mw))
  expect_true("bank_POINT_Y" %in% colnames(mw))
  expect_true("bank_POINT_M" %in% colnames(mw))
  expect_true("DEM_Z" %in% colnames(mw))
  expect_true("valley_POINT_X" %in% colnames(mw))
  expect_true("valley_POINT_Y" %in% colnames(mw))
  expect_true("valley_POINT_M" %in% colnames(mw))
  expect_true("downstream_x" %in% colnames(mw))
  expect_true("downstream_y" %in% colnames(mw))
  expect_true("downstream_v_x" %in% colnames(mw))
  expect_true("downstream_v_y" %in% colnames(mw))
  expect_true("current_loop_width" %in% colnames(mw))
  expect_true("next_loop_width" %in% colnames(mw))
  expect_true("meander_width" %in% colnames(mw))
  expect_true(is.integer(mw$loop))
  expect_true(is.numeric(mw$bank_POINT_X))
  expect_true(is.numeric(mw$bank_POINT_Y))
  expect_true(is.numeric(mw$bank_POINT_M))
  expect_true(is.numeric(mw$DEM_Z))
  expect_true(is.numeric(mw$valley_POINT_X))
  expect_true(is.numeric(mw$valley_POINT_Y))
  expect_true(is.numeric(mw$valley_POINT_M))
  expect_true(is.numeric(mw$downstream_y))
  expect_true(is.numeric(mw$downstream_x))
  expect_true(is.numeric(mw$downstream_v_y))
  expect_true(is.numeric(mw$downstream_v_x))
  expect_true(is.numeric(mw$current_loop_width))
  expect_true(is.numeric(mw$next_loop_width))
  expect_true(is.numeric(mw$meander_width))
})

test_that("check output", {
  expect_equal(length(mw$loop),
               length(unique(na.omit(fluvgeo::sin_bankline_points_sf$loop))) )
})
FluvialGeomorph/fluvgeo documentation built on Feb. 19, 2025, 4:24 p.m.