test_that("CDATA creation works", {
x <- xml_new_root("root")
xml_add_child(x, xml_cdata(""))
expect_identical(as.character(x), "\n]]>\n")
})
test_that("Comment creation works", {
x <- xml_new_root("root")
xml_add_child(x, xml_comment("Hello!"))
expect_identical("\n\n", as.character(x, options = ""))
})
test_that("xml_dtd works", {
r <- xml_new_root(xml_dtd(name = "html", external_id = "-//W3C//DTD XHTML 1.0 Transitional//EN", system_id = "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"))
expect_identical("\n\n", as.character(r))
no_name <- xml_new_root(xml_dtd(external_id = "-//W3C//DTD XHTML 1.0 Transitional//EN", system_id = "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"))
expect_identical("\n\n", as.character(no_name))
no_name_external_id <- xml_new_root(xml_dtd(system_id = "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"))
expect_identical("\n\n", as.character(no_name_external_id))
no_name_external_id_internal_id <- xml_new_root(xml_dtd())
expect_identical("\n\n", as.character(no_name_external_id_internal_id))
})