File: test-xml_type.R

package info (click to toggle)
r-cran-xml2 1.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 976 kB
  • sloc: cpp: 1,826; xml: 333; javascript: 238; ansic: 178; sh: 71; makefile: 6
file content (18 lines) | stat: -rw-r--r-- 460 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
test_that("xml_type() works", {
  x <- read_xml("<body>
    <p>Some <b>text</b>.</p>
    <p>Some <i>other</i>.</p>
    <p>No bold text</p>
    </body>")

  children <- xml_children(x)
  x <- xml_find_first(children, ".//b|.//i")

  expect_equal(xml_type(x[[1]]), "element")
  expect_equal(xml_type(x[[3]]), NA_character_)

  expect_equal(xml_type(x), c("element", "element", NA))

  empty <- xml_children(x)
  expect_identical(xml_type(empty), character())
})