From 4d39ae9e45363b5082c308fc79bb90fa96dc3ed3 Mon Sep 17 00:00:00 2001 From: Arseny Kapoulkine Date: Thu, 2 Oct 2014 03:07:08 +0000 Subject: tests: Add a test to verify that xml_document object works with any valid pointer alignment git-svn-id: https://pugixml.googlecode.com/svn/trunk@1039 99668b35-9821-0410-8761-19e4c4f06640 --- tests/test_document.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'tests') diff --git a/tests/test_document.cpp b/tests/test_document.cpp index c34eb42..c75ed8f 100644 --- a/tests/test_document.cpp +++ b/tests/test_document.cpp @@ -1220,3 +1220,18 @@ TEST(document_load_stream_truncated) } } #endif + +TEST(document_alignment) +{ + char buf[256 + sizeof(xml_document)]; + + for (size_t offset = 0; offset < 256; offset += sizeof(void*)) + { + xml_document* doc = new (buf + offset) xml_document; + + CHECK(doc->load(STR(""))); + CHECK_NODE(*doc, STR("")); + + doc->~xml_document(); + } +} -- cgit v1.2.3