From 04629118dbde33fdedfe489119f34912f8e7c124 Mon Sep 17 00:00:00 2001 From: "arseny.kapoulkine@gmail.com" Date: Tue, 6 Mar 2012 08:49:58 +0000 Subject: tests: Android compilation fixes git-svn-id: http://pugixml.googlecode.com/svn/trunk@846 99668b35-9821-0410-8761-19e4c4f06640 --- tests/main.cpp | 5 ++++- tests/test_document.cpp | 4 ++-- tests/test_unicode.cpp | 8 ++++---- tests/test_write.cpp | 2 +- tests/writer_string.cpp | 6 +++--- tests/writer_string.hpp | 4 ++-- 6 files changed, 16 insertions(+), 13 deletions(-) (limited to 'tests') 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 #include #include #include #include +#ifndef PUGIXML_NO_EXCEPTIONS +# include +#endif + #ifdef _WIN32_WCE # undef DebugBreak # include 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 // 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 // for unlink #endif @@ -382,7 +382,7 @@ TEST_XML(document_save_declaration_latin1, "") CHECK(writer.as_narrow() == "\n\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 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 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 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 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 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 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(static_cast(contents.data())), contents.size() / sizeof(wchar_t)); + return std::basic_string(static_cast(static_cast(contents.data())), contents.size() / sizeof(wchar_t)); } std::basic_string 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 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 as_wide() const; std::basic_string 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 write_wide(pugi::xml_node node, unsigned int flags, pugi::xml_encoding encoding); #endif -- cgit v1.2.3