0
0
mirror of https://github.com/zeux/pugixml.git synced 2024-12-27 13:33:17 +08:00

tests: Fixed compilation errors for BadaSDK

git-svn-id: http://pugixml.googlecode.com/svn/trunk@839 99668b35-9821-0410-8761-19e4c4f06640
This commit is contained in:
arseny.kapoulkine@gmail.com 2012-03-06 06:13:10 +00:00
parent 6e02258ef6
commit fdc03d39ab
5 changed files with 10 additions and 10 deletions

View File

@ -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__) #if defined(__CELLOS_LV2__) || defined(_GLIBCXX_HAVE_UNISTD_H)
# include <unistd.h> // for unlink # include <unistd.h> // for unlink
#endif #endif
@ -528,13 +528,12 @@ inline void check_utftest_document(const xml_document& doc)
const pugi::char_t* v = doc.last_child().child(STR("Heavy")).previous_sibling().child_value(); const pugi::char_t* v = doc.last_child().child(STR("Heavy")).previous_sibling().child_value();
#ifdef PUGIXML_WCHAR_MODE #ifdef PUGIXML_WCHAR_MODE
CHECK(v[0] == 0x4e16 && v[1] == 0x754c && v[2] == 0x6709 && v[3] == 0x5f88 && v[4] == 0x591a && v[5] == 0x8bed && v[6] == 0x8a00); CHECK(v[0] == 0x4e16 && v[1] == 0x754c && v[2] == 0x6709 && v[3] == 0x5f88 && v[4] == 0x591a && v[5] == wchar_cast(0x8bed) && v[6] == wchar_cast(0x8a00));
// last character is a surrogate pair // last character is a surrogate pair
unsigned int v7 = v[7];
size_t wcharsize = sizeof(wchar_t); size_t wcharsize = sizeof(wchar_t);
CHECK(wcharsize == 2 ? (v[7] == 0xd852 && v[8] == 0xdf62) : (v7 == 0x24b62)); CHECK(wcharsize == 2 ? (v[7] == wchar_cast(0xd852) && v[8] == wchar_cast(0xdf62)) : (v[7] == wchar_cast(0x24b62)));
#else #else
// unicode string // unicode string
CHECK_STRING(v, "\xe4\xb8\x96\xe7\x95\x8c\xe6\x9c\x89\xe5\xbe\x88\xe5\xa4\x9a\xe8\xaf\xad\xe8\xa8\x80\xf0\xa4\xad\xa2"); CHECK_STRING(v, "\xe4\xb8\x96\xe7\x95\x8c\xe6\x9c\x89\xe5\xbe\x88\xe5\xa4\x9a\xe8\xaf\xad\xe8\xa8\x80\xf0\xa4\xad\xa2");

View File

@ -443,10 +443,9 @@ TEST(parse_escapes_unicode)
#ifdef PUGIXML_WCHAR_MODE #ifdef PUGIXML_WCHAR_MODE
const pugi::char_t* v = doc.child_value(STR("node")); const pugi::char_t* v = doc.child_value(STR("node"));
unsigned int v2 = v[2];
size_t wcharsize = sizeof(wchar_t); size_t wcharsize = sizeof(wchar_t);
CHECK(v[0] == 0x3b3 && v[1] == 0x3b3 && (wcharsize == 2 ? v[2] == 0xd852 && v[3] == 0xdf62 : v2 == 0x24b62)); CHECK(v[0] == 0x3b3 && v[1] == 0x3b3 && (wcharsize == 2 ? v[2] == wchar_cast(0xd852) && v[3] == wchar_cast(0xdf62) : v[2] == wchar_cast(0x24b62)));
#else #else
CHECK_STRING(doc.child_value(STR("node")), "\xce\xb3\xce\xb3\xf0\xa4\xad\xa2"); CHECK_STRING(doc.child_value(STR("node")), "\xce\xb3\xce\xb3\xf0\xa4\xad\xa2");
#endif #endif

View File

@ -34,7 +34,7 @@ TEST(as_wide_valid_astral)
} }
else else
{ {
CHECK(b4.size() == 5 && b4[0] == 0xda1d && b4[1] == 0xde24 && b4[2] == L' ' && b4[3] == 0xdbc0 && b4[4] == 0xdfff); CHECK(b4.size() == 5 && b4[0] == wchar_cast(0xda1d) && b4[1] == wchar_cast(0xde24) && b4[2] == L' ' && b4[3] == wchar_cast(0xdbc0) && b4[4] == wchar_cast(0xdfff));
} }
} }

View File

@ -187,7 +187,7 @@ TEST(write_encodings)
} }
else else
{ {
CHECK(v.size() == 10 && v[0] == '<' && v[1] == 0x54 && v[2] == 0xA2 && v[3] == 0x20AC && v[4] == 0xd852 && v[5] == 0xdf62 && v[6] == ' ' && v[7] == '/' && v[8] == '>' && v[9] == '\n'); CHECK(v.size() == 10 && v[0] == '<' && v[1] == 0x54 && v[2] == 0xA2 && v[3] == 0x20AC && v[4] == wchar_cast(0xd852) && v[5] == wchar_cast(0xdf62) && v[6] == ' ' && v[7] == '/' && v[8] == '>' && v[9] == '\n');
} }
CHECK(test_write_narrow(doc, format_default, encoding_latin1, "<\x54\xA2?? />\n", 9)); CHECK(test_write_narrow(doc, format_default, encoding_latin1, "<\x54\xA2?? />\n", 9));

View File

@ -27,7 +27,8 @@ std::wstring xml_writer_string::as_wide() const
{ {
CHECK(contents.size() % sizeof(wchar_t) == 0); CHECK(contents.size() % sizeof(wchar_t) == 0);
return std::wstring(reinterpret_cast<const wchar_t*>(contents.data()), contents.size() / sizeof(wchar_t)); // 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));
} }
std::basic_string<pugi::char_t> xml_writer_string::as_string() const std::basic_string<pugi::char_t> xml_writer_string::as_string() const
@ -36,7 +37,8 @@ std::basic_string<pugi::char_t> xml_writer_string::as_string() const
CHECK(contents.size() % sizeof(pugi::char_t) == 0); CHECK(contents.size() % sizeof(pugi::char_t) == 0);
#endif #endif
return std::basic_string<pugi::char_t>(reinterpret_cast<const pugi::char_t*>(contents.data()), contents.size() / sizeof(pugi::char_t)); // round-trip pointer through void* to avoid pointer alignment warnings; contents data should be heap allocated => safe to cast
return std::basic_string<pugi::char_t>(static_cast<const pugi::char_t*>(static_cast<const void*>(contents.data())), contents.size() / sizeof(pugi::char_t));
} }
std::string save_narrow(const pugi::xml_document& doc, unsigned int flags, pugi::xml_encoding encoding) std::string save_narrow(const pugi::xml_document& doc, unsigned int flags, pugi::xml_encoding encoding)