[cpp-sp] 01/02: Add a UTF-8 parsing test.

Scott Cantor cantor.2 at osu.edu
Wed Nov 6 13:40:21 UTC 2024


This is an automated email from the git hooks/post-receive script.

scantor pushed a commit to branch main
in repository cpp-sp.

View the commit online:
http://git.shibboleth.net/view/?p=cpp-sp.git;a=commit;h=af6ef93b484d6735b21fc0b129ed12641613f0ea

commit af6ef93b484d6735b21fc0b129ed12641613f0ea
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Tue Nov 5 19:44:46 2024 -0500

    Add a UTF-8 parsing test.
---
 tests/PropertyTreeTests.cpp             | 29 +++++++++++++++++++++++++++--
 tests/data/propertytree/requestmap2.xml |  5 +++++
 2 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/tests/PropertyTreeTests.cpp b/tests/PropertyTreeTests.cpp
index dbb4e86a..f42f8be5 100644
--- a/tests/PropertyTreeTests.cpp
+++ b/tests/PropertyTreeTests.cpp
@@ -18,7 +18,6 @@
  * Unit tests for property tree usage.
  */
 
-#include <iostream>
 #include <boost/test/unit_test.hpp>
 #include <boost/property_tree/xml_parser.hpp>
 
@@ -40,7 +39,7 @@ BOOST_FIXTURE_TEST_CASE(PropertyTree_RequestMap_simple, PT_Fixture)
     BOOST_CHECK_EQUAL(tree.size(), 1);
 
     const pt::ptree& requestMap = tree.get_child("RequestMap");
-    BOOST_CHECK(requestMap.size() == 2);
+    BOOST_CHECK_EQUAL(requestMap.size(), 2);
 
     for (const pair<string,pt::ptree>& child : requestMap) {
         BOOST_CHECK_EQUAL(child.first, "Host");
@@ -65,3 +64,29 @@ BOOST_FIXTURE_TEST_CASE(PropertyTree_RequestMap_simple, PT_Fixture)
         }
     }
 }
+
+BOOST_FIXTURE_TEST_CASE(PropertyTree_RequestMap_utf8, PT_Fixture)
+{
+    pt::ptree tree;
+    pt::read_xml(data_path + "requestmap2.xml", tree);
+
+    BOOST_CHECK_EQUAL(tree.size(), 1);
+
+    const pt::ptree& requestMap = tree.get_child("RequestMap");
+    BOOST_CHECK_EQUAL(requestMap.size(), 1);
+
+    for (const pair<string,pt::ptree>& child : requestMap) {
+        BOOST_CHECK_EQUAL(child.first, "Host");
+
+        BOOST_CHECK_EQUAL(child.second.size(), 2);
+        const pt::ptree& attrs = child.second.get_child("<xmlattr>");
+        string name = attrs.get<string>("name");
+        if (name == "sp.example.org") {
+            BOOST_CHECK_EQUAL(attrs.size(), 1);
+            BOOST_CHECK_EQUAL(child.second.get<string>("Path.<xmlattr>.name"), "secure/☯️");
+            BOOST_CHECK_EQUAL(child.second.get<string>("Path.<xmlattr>.requireSession"), "true");
+        } else {
+            BOOST_ERROR("Unexpected Host name: " << name);
+        }
+    }
+}
diff --git a/tests/data/propertytree/requestmap2.xml b/tests/data/propertytree/requestmap2.xml
new file mode 100644
index 00000000..a5121b46
--- /dev/null
+++ b/tests/data/propertytree/requestmap2.xml
@@ -0,0 +1,5 @@
+<RequestMap>
+    <Host name="sp.example.org">
+        <Path name="secure/☯️" requireSession="true" />
+    </Host>
+</RequestMap>

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list