mirror of
https://github.com/zeux/pugixml.git
synced 2024-12-28 06:10:55 +08:00
tests: Android compilation fixes
git-svn-id: http://pugixml.googlecode.com/svn/trunk@846 99668b35-9821-0410-8761-19e4c4f06640
This commit is contained in:
parent
72dd6038a2
commit
04629118db
@ -1,12 +1,15 @@
|
|||||||
#include "test.hpp"
|
#include "test.hpp"
|
||||||
#include "allocator.hpp"
|
#include "allocator.hpp"
|
||||||
|
|
||||||
#include <exception>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <float.h>
|
#include <float.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
|
#ifndef PUGIXML_NO_EXCEPTIONS
|
||||||
|
# include <exception>
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef _WIN32_WCE
|
#ifdef _WIN32_WCE
|
||||||
# undef DebugBreak
|
# undef DebugBreak
|
||||||
# include <windows.h>
|
# include <windows.h>
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
# include <io.h> // for unlink in C++0x mode
|
# include <io.h> // for unlink in C++0x mode
|
||||||
#endif
|
#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
|
# include <unistd.h> // for unlink
|
||||||
#endif
|
#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");
|
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
|
struct temp_file
|
||||||
{
|
{
|
||||||
|
@ -24,7 +24,7 @@ TEST(as_wide_valid_basic)
|
|||||||
TEST(as_wide_valid_astral)
|
TEST(as_wide_valid_astral)
|
||||||
{
|
{
|
||||||
// valid 4-byte input
|
// 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);
|
size_t wcharsize = sizeof(wchar_t);
|
||||||
|
|
||||||
@ -65,7 +65,7 @@ TEST(as_wide_invalid)
|
|||||||
CHECK(as_wide("a\xf2_") == L"a_");
|
CHECK(as_wide("a\xf2_") == L"a_");
|
||||||
|
|
||||||
// invalid 5-byte input
|
// 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");
|
CHECK(b5 == L"\nbcd");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,7 +98,7 @@ TEST(as_utf8_valid_astral)
|
|||||||
|
|
||||||
if (wcharsize == 4)
|
if (wcharsize == 4)
|
||||||
{
|
{
|
||||||
std::wstring s;
|
std::basic_string<wchar_t> s;
|
||||||
s.resize(3);
|
s.resize(3);
|
||||||
s[0] = wchar_cast(0x97624);
|
s[0] = wchar_cast(0x97624);
|
||||||
s[1] = ' ';
|
s[1] = ' ';
|
||||||
@ -144,7 +144,7 @@ TEST(as_utf8_invalid)
|
|||||||
|
|
||||||
TEST(as_utf8_string)
|
TEST(as_utf8_string)
|
||||||
{
|
{
|
||||||
std::wstring s = L"abcd";
|
std::basic_string<wchar_t> s = L"abcd";
|
||||||
|
|
||||||
CHECK(as_utf8(s) == "abcd");
|
CHECK(as_utf8(s) == "abcd");
|
||||||
}
|
}
|
||||||
|
@ -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));
|
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);
|
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)
|
if (wcharsize == 4)
|
||||||
{
|
{
|
||||||
|
@ -23,12 +23,12 @@ std::string xml_writer_string::as_narrow() const
|
|||||||
return contents;
|
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);
|
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
|
// 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
|
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);
|
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;
|
xml_writer_string writer;
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ struct xml_writer_string: public pugi::xml_writer
|
|||||||
virtual void write(const void* data, size_t size);
|
virtual void write(const void* data, size_t size);
|
||||||
|
|
||||||
std::string as_narrow() const;
|
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;
|
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);
|
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);
|
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
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user