summary refs log tree commit diff stats
path: root/tests/xml/ttree_replace1.nim
diff options
context:
space:
mode:
authorMichael Voronin <survivor.mail@gmail.com>2022-12-22 10:32:12 +0300
committerGitHub <noreply@github.com>2022-12-22 08:32:12 +0100
commit7931bdac956cb3ad6734eab91c62920f4e80f919 (patch)
tree08f275175573391aa327587198a30fbb685343cf /tests/xml/ttree_replace1.nim
parent93b59da4902886cd68dd7df1dce09a1b455a06dc (diff)
downloadNim-7931bdac956cb3ad6734eab91c62920f4e80f919.tar.gz
Feature/xmltree additions (#20988)
* [change] add/insert/delete family of xmltree expanded with several variations. Added replace methods family

* [change] Lifted child limitations on insert methods (consulted with @araq)

* [tests] add/insert/replace/delete of xmltree XmlNodes tests added
Diffstat (limited to 'tests/xml/ttree_replace1.nim')
-rw-r--r--tests/xml/ttree_replace1.nim53
1 files changed, 53 insertions, 0 deletions
diff --git a/tests/xml/ttree_replace1.nim b/tests/xml/ttree_replace1.nim
new file mode 100644
index 000000000..059ce2085
--- /dev/null
+++ b/tests/xml/ttree_replace1.nim
@@ -0,0 +1,53 @@
+discard """
+  output: '''
+<xml>
+  <head>
+    <div>Some text</div>
+    <div>Some more text </div>
+  </head>
+  <body>
+    <div>Some text in body</div>
+    <div>Some more text in body </div>
+  </body>
+</xml>
+'''
+"""
+
+# Test xmltree add/insert/delete/replace operations
+import xmlparser
+import xmltree
+var baseDocHead = """
+  <head>
+    <div>Some text</div>
+    <div>Some more text </div>
+  </head>
+"""
+var baseDocHeadTree = parseXml(baseDocHead)
+var baseDocBody = """
+<body>
+  <div>Some text in body</div>
+  <div>Some more text in body </div>
+</body>
+"""
+var baseDocBodyTree = parseXml(baseDocBody)
+let initialDocBase = """
+<xml>
+  <head>
+    <div>Some text before replace </div>
+    <div>Some more text before replace </div>
+  </head>
+  <body>
+    <div>Some text in body before replace </div>
+    <div>Some more text in body before replace </div>
+  </body>
+</xml>
+"""
+var initialDocBaseTree = parseXml(initialDocBase)
+
+proc test_replace() =
+  var testDoc = initialDocBaseTree
+  
+  testDoc.replace(0..1, @[baseDocHeadTree, baseDocBodyTree])
+  echo $testDoc
+
+test_replace()