tests/testthat/test-get_xml_opening_tag.R

context("get_xml_opening_tag")

test_that("use '<tag text=hello</tag>'", {

  xml <- "<parameter id=\"birthRate.t:anthus_aco_sub\" name=\"stateNode\">1.0</parameter>" # nolint XML can be long

  created <- get_xml_opening_tag(xml)
  expected <- "parameter"
  testthat::expect_equal(created, expected)

})

test_that("use '<tag text=hello/>'", {

  xml <- "<taxon id=\"630116_aco\" spec=\"Taxon\"/>" # nolint this is no absolute path
  created <- get_xml_opening_tag(xml)
  expected <- "taxon"
  testthat::expect_equal(created, expected)

})

test_that("No tag gives NA", {

  testthat::expect_true(
    is_one_na(
      get_xml_opening_tag("no xml")
    )
  )
})
richelbilderbeek/beastscriptr documentation built on Nov. 5, 2023, 8:36 p.m.