[libxmlplusplus] tests: Don't require C++17



commit 223ffdd9ba8e96b88d316acd86b1dbedadef8019
Author: Kjell Ahlstedt <kjellahlstedt gmail com>
Date:   Sat Jul 14 10:49:32 2018 +0200

    tests: Don't require C++17
    
    Don't include glibmm.h and don't call Glib::init(). Then no included
    header file requires C++17 support, just C++14 support.
    Glib::init() is not necessary, because libxml++ uses only a small part
    of glibmm, mainly Glib::ustring.

 tests/saxparser_chunk_parsing_inconsistent_state/main.cc | 5 +++--
 tests/saxparser_parse_double_free/main.cc                | 5 +++--
 tests/saxparser_parse_stream_inconsistent_state/main.cc  | 5 +++--
 3 files changed, 9 insertions(+), 6 deletions(-)
---
diff --git a/tests/saxparser_chunk_parsing_inconsistent_state/main.cc 
b/tests/saxparser_chunk_parsing_inconsistent_state/main.cc
index 136bfb7..ab44d0b 100644
--- a/tests/saxparser_chunk_parsing_inconsistent_state/main.cc
+++ b/tests/saxparser_chunk_parsing_inconsistent_state/main.cc
@@ -19,7 +19,6 @@
 #include <libxml++/libxml++.h>
 
 #include <cstdlib>
-#include <glibmm.h>
 #include <sstream>
 #include <stdexcept>
 
@@ -38,7 +37,9 @@ protected:
 
 int main()
 {
-  Glib::init();
+  // Set the global C and C++ locale to the user-configured locale,
+  // so we can use std::cout with UTF-8, via Glib::ustring, without exceptions.
+  std::locale::global(std::locale(""));
 
   {
     MySaxParser parser;
diff --git a/tests/saxparser_parse_double_free/main.cc b/tests/saxparser_parse_double_free/main.cc
index e1bd3b6..09af02e 100644
--- a/tests/saxparser_parse_double_free/main.cc
+++ b/tests/saxparser_parse_double_free/main.cc
@@ -19,7 +19,6 @@
 #include <libxml++/libxml++.h>
 
 #include <cstdlib>
-#include <glibmm.h>
 #include <stdexcept>
 
 class OnCdataBlockTestParser : public xmlpp::SaxParser
@@ -340,7 +339,9 @@ void test_on_start_element()
 
 int main()
 {
-  Glib::init();
+  // Set the global C and C++ locale to the user-configured locale,
+  // so we can use std::cout with UTF-8, via Glib::ustring, without exceptions.
+  std::locale::global(std::locale(""));
 
   test_on_cdata_block();
   test_on_characters();
diff --git a/tests/saxparser_parse_stream_inconsistent_state/main.cc 
b/tests/saxparser_parse_stream_inconsistent_state/main.cc
index 4fd1320..6be414e 100644
--- a/tests/saxparser_parse_stream_inconsistent_state/main.cc
+++ b/tests/saxparser_parse_stream_inconsistent_state/main.cc
@@ -19,7 +19,6 @@
 #include <libxml++/libxml++.h>
 
 #include <cstdlib>
-#include <glibmm.h>
 #include <sstream>
 #include <stdexcept>
 
@@ -34,7 +33,9 @@ protected:
 
 int main()
 {
-  Glib::init();
+  // Set the global C and C++ locale to the user-configured locale,
+  // so we can use std::cout with UTF-8, via Glib::ustring, without exceptions.
+  std::locale::global(std::locale(""));
 
   {
     MySaxParser parser;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]