summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/main.cpp5
-rw-r--r--tests/test_document.cpp4
-rw-r--r--tests/test_unicode.cpp8
-rw-r--r--tests/test_write.cpp2
-rw-r--r--tests/writer_string.cpp6
-rw-r--r--tests/writer_string.hpp4
6 files changed, 16 insertions, 13 deletions
diff --git a/tests/main.cpp b/tests/main.cpp
index 21e9e6a..d580a03 100644
--- a/tests/main.cpp
+++ b/tests/main.cpp
@@ -1,12 +1,15 @@
#include "test.hpp"
#include "allocator.hpp"
-#include <exception>
#include <stdio.h>
#include <stdlib.h>
#include <float.h>
#include <assert.h>
+#ifndef PUGIXML_NO_EXCEPTIONS
+# include <exception>
+#endif
+
#ifdef _WIN32_WCE
# undef DebugBreak
# include <windows.h>
diff --git a/tests/test_document.cpp b/tests/test_document.cpp
index a34513e..c8345f0 100644
--- a/tests/test_document.cpp
+++ b/tests/test_document.cpp
@@ -22,7 +22,7 @@
# include <io.h> // for unlink in C++0x mode
#endif
-#if defined(__CELLOS_LV2__) || defined(_GLIBCXX_HAVE_UNISTD_H)
+#if defined(__CELLOS_LV2__) || defined(ANDROID) || defined(_GLIBCXX_HAVE_UNISTD_H)
# include <unistd.h> // for unlink
#endif
@@ -382,7 +382,7 @@ TEST_XML(document_save_declaration_latin1, "<node/>")
CHECK(writer.as_narrow() == "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n<node />\n");
}
-#define USE_MKSTEMP defined(__unix) || defined(__QNX__)
+#define USE_MKSTEMP defined(__unix) || defined(__QNX__) || defined(ANDROID)
struct temp_file
{
diff --git a/tests/test_unicode.cpp b/tests/test_unicode.cpp
index c1a5533..1902e36 100644
--- a/tests/test_unicode.cpp
+++ b/tests/test_unicode.cpp
@@ -24,7 +24,7 @@ TEST(as_wide_valid_basic)
TEST(as_wide_valid_astral)
{
// valid 4-byte input
- std::wstring b4 = as_wide("\xf2\x97\x98\xa4 \xf4\x80\x8f\xbf");
+ std::basic_string<wchar_t> b4 = as_wide("\xf2\x97\x98\xa4 \xf4\x80\x8f\xbf");
size_t wcharsize = sizeof(wchar_t);
@@ -65,7 +65,7 @@ TEST(as_wide_invalid)
CHECK(as_wide("a\xf2_") == L"a_");
// invalid 5-byte input
- std::wstring b5 = as_wide("\xf8\nbcd");
+ std::basic_string<wchar_t> b5 = as_wide("\xf8\nbcd");
CHECK(b5 == L"\nbcd");
}
@@ -98,7 +98,7 @@ TEST(as_utf8_valid_astral)
if (wcharsize == 4)
{
- std::wstring s;
+ std::basic_string<wchar_t> s;
s.resize(3);
s[0] = wchar_cast(0x97624);
s[1] = ' ';
@@ -144,7 +144,7 @@ TEST(as_utf8_invalid)
TEST(as_utf8_string)
{
- std::wstring s = L"abcd";
+ std::basic_string<wchar_t> s = L"abcd";
CHECK(as_utf8(s) == "abcd");
}
diff --git a/tests/test_write.cpp b/tests/test_write.cpp
index 9a83e0e..de6f03d 100644
--- a/tests/test_write.cpp
+++ b/tests/test_write.cpp
@@ -179,7 +179,7 @@ TEST(write_encodings)
CHECK(write_narrow(doc, format_default, encoding_utf16) == write_narrow(doc, format_default, is_little_endian() ? encoding_utf16_le : encoding_utf16_be));
size_t wcharsize = sizeof(wchar_t);
- std::wstring v = write_wide(doc, format_default, encoding_wchar);
+ std::basic_string<wchar_t> v = write_wide(doc, format_default, encoding_wchar);
if (wcharsize == 4)
{
diff --git a/tests/writer_string.cpp b/tests/writer_string.cpp
index 1b94d20..a09678b 100644
--- a/tests/writer_string.cpp
+++ b/tests/writer_string.cpp
@@ -23,12 +23,12 @@ std::string xml_writer_string::as_narrow() const
return contents;
}
-std::wstring xml_writer_string::as_wide() const
+std::basic_string<wchar_t> xml_writer_string::as_wide() const
{
CHECK(contents.size() % sizeof(wchar_t) == 0);
// round-trip pointer through void* to avoid pointer alignment warnings; contents data should be heap allocated => safe to cast
- return std::wstring(static_cast<const wchar_t*>(static_cast<const void*>(contents.data())), contents.size() / sizeof(wchar_t));
+ return std::basic_string<wchar_t>(static_cast<const wchar_t*>(static_cast<const void*>(contents.data())), contents.size() / sizeof(wchar_t));
}
std::basic_string<pugi::char_t> xml_writer_string::as_string() const
@@ -69,7 +69,7 @@ bool test_write_narrow(pugi::xml_node node, unsigned int flags, pugi::xml_encodi
return test_narrow(write_narrow(node, flags, encoding), expected, length);
}
-std::wstring write_wide(pugi::xml_node node, unsigned int flags, pugi::xml_encoding encoding)
+std::basic_string<wchar_t> write_wide(pugi::xml_node node, unsigned int flags, pugi::xml_encoding encoding)
{
xml_writer_string writer;
diff --git a/tests/writer_string.hpp b/tests/writer_string.hpp
index 390f93b..6bffc32 100644
--- a/tests/writer_string.hpp
+++ b/tests/writer_string.hpp
@@ -12,7 +12,7 @@ struct xml_writer_string: public pugi::xml_writer
virtual void write(const void* data, size_t size);
std::string as_narrow() const;
- std::wstring as_wide() const;
+ std::basic_string<wchar_t> as_wide() const;
std::basic_string<pugi::char_t> as_string() const;
};
@@ -22,6 +22,6 @@ bool test_save_narrow(const pugi::xml_document& doc, unsigned int flags, pugi::x
std::string write_narrow(pugi::xml_node node, unsigned int flags, pugi::xml_encoding encoding);
bool test_write_narrow(pugi::xml_node node, unsigned int flags, pugi::xml_encoding encoding, const char* expected, size_t length);
-std::wstring write_wide(pugi::xml_node node, unsigned int flags, pugi::xml_encoding encoding);
+std::basic_string<wchar_t> write_wide(pugi::xml_node node, unsigned int flags, pugi::xml_encoding encoding);
#endif