From e286783c61d24e4eb9bde056da6a76a21aab6afa Mon Sep 17 00:00:00 2001
From: Lee Dong Wook <sh95119@gmail.com>
Date: Mon, 22 Aug 2022 22:42:38 +0900
Subject: [PATCH] xml2: add test for coverage

---
 contrib/xml2/expected/xml2.out | 36 ++++++++++++++++++++++++++++++++++
 contrib/xml2/sql/xml2.sql      |  8 ++++++++
 2 files changed, 44 insertions(+)

diff --git a/contrib/xml2/expected/xml2.out b/contrib/xml2/expected/xml2.out
index eba6ae603649..dd88e1747e30 100644
--- a/contrib/xml2/expected/xml2.out
+++ b/contrib/xml2/expected/xml2.out
@@ -88,6 +88,18 @@ as t(id int4, doc int4);
   1 |   1
 (1 row)
 
+select * from xml_valid('xpath_test');
+ xml_valid 
+-----------
+ t
+(1 row)
+
+select xml_encode_special_chars('<doc><int>1</int></doc>');
+            xml_encode_special_chars             
+-------------------------------------------------
+ &lt;doc&gt;&lt;int&gt;1&lt;/int&gt;&lt;/doc&gt;
+(1 row)
+
 create table articles (article_id integer, article_xml xml, date_entered date);
 insert into articles (article_id, article_xml, date_entered)
 values (2, '<article><author>test</author><pages>37</pages></article>', now());
@@ -139,6 +151,30 @@ values
 Value</attribute></attributes>');
 create index idx_xpath on t1 ( xpath_string
 ('/attributes/attribute[@name="attr_1"]/text()', xml_data::text));
+select xpath_number('/attributes/attribute[@name="attr_1"]/', xml_data::text) from t1;
+ xpath_number 
+--------------
+             
+(1 row)
+
+select xpath_bool('/attributes/attribute[@name="attr_1"]/', xml_data::text) from t1;
+ xpath_bool 
+------------
+ f
+(1 row)
+
+select xpath_nodeset('/attributes/attribute[@name="attr_1"]/', xml_data::text) from t1;
+ xpath_nodeset 
+---------------
+ 
+(1 row)
+
+select xpath_list('/attributes/attribute[@name="attr_1"]/', xml_data::text) from t1;
+ xpath_list 
+------------
+ 
+(1 row)
+
 SELECT xslt_process('<employee><name>cim</name><age>30</age><pay>400</pay></employee>'::text, $$<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
   <xsl:output method="xml" omit-xml-declaration="yes" indent="yes"/>
   <xsl:strip-space elements="*"/>
diff --git a/contrib/xml2/sql/xml2.sql b/contrib/xml2/sql/xml2.sql
index ac49cfa7c523..2f1c2614f231 100644
--- a/contrib/xml2/sql/xml2.sql
+++ b/contrib/xml2/sql/xml2.sql
@@ -34,6 +34,9 @@ as t(id int4);
 SELECT * FROM xpath_table('id', 't', 'xpath_test', '/doc/int', 'true')
 as t(id int4, doc int4);
 
+select * from xml_valid('xpath_test');
+select xml_encode_special_chars('<doc><int>1</int></doc>');
+
 create table articles (article_id integer, article_xml xml, date_entered date);
 insert into articles (article_id, article_xml, date_entered)
 values (2, '<article><author>test</author><pages>37</pages></article>', now());
@@ -73,6 +76,11 @@ Value</attribute></attributes>');
 create index idx_xpath on t1 ( xpath_string
 ('/attributes/attribute[@name="attr_1"]/text()', xml_data::text));
 
+select xpath_number('/attributes/attribute[@name="attr_1"]/', xml_data::text) from t1;
+select xpath_bool('/attributes/attribute[@name="attr_1"]/', xml_data::text) from t1;
+select xpath_nodeset('/attributes/attribute[@name="attr_1"]/', xml_data::text) from t1;
+select xpath_list('/attributes/attribute[@name="attr_1"]/', xml_data::text) from t1;
+
 SELECT xslt_process('<employee><name>cim</name><age>30</age><pay>400</pay></employee>'::text, $$<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
   <xsl:output method="xml" omit-xml-declaration="yes" indent="yes"/>
   <xsl:strip-space elements="*"/>
