File: test-format.R

package info (click to toggle)
r-cran-xml2 1.5.2-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 976 kB
  • sloc: cpp: 1,828; xml: 333; javascript: 238; ansic: 213; sh: 74; makefile: 6
file content (22 lines) | stat: -rw-r--r-- 663 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
test_that("format.xml_node prints attributes for root nodes", {
  x <- read_xml("<parent foo = 'bar' />")
  expect_equal(format(x), "<parent foo=\"bar\">")
})
test_that("format.xml_node prints namespaces for root nodes", {
  x <- read_xml("<parent/>")
  expect_equal(format(x), "<parent>")

  y <- read_xml("<parent xmlns = 'tag:james.f.hester@gmail.com,2016:bar' />")
  expect_equal(
    format(y),
    "<parent xmlns=\"tag:james.f.hester@gmail.com,2016:bar\">"
  )

  z <- read_xml(
    "<parent xmlns:foo = 'tag:james.f.hester@gmail.com,2016:bar' />"
  )
  expect_equal(
    format(z),
    "<parent xmlns:foo=\"tag:james.f.hester@gmail.com,2016:bar\">"
  )
})