From 958ee27e7fafb0bc5702ac3959cebaf18dce68e0 Mon Sep 17 00:00:00 2001 From: "arseny.kapoulkine" Date: Thu, 22 Jul 2010 17:22:44 +0000 Subject: tests: Miscellaneous test fixes git-svn-id: http://pugixml.googlecode.com/svn/trunk@618 99668b35-9821-0410-8761-19e4c4f06640 --- tests/test_document.cpp | 8 +++++--- tests/test_xpath.cpp | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) (limited to 'tests') diff --git a/tests/test_document.cpp b/tests/test_document.cpp index 35f3f7d..85a63a7 100644 --- a/tests/test_document.cpp +++ b/tests/test_document.cpp @@ -108,15 +108,17 @@ TEST(document_load_stream_exceptions) { pugi::xml_document doc; + // Windows has newline translation for text-mode files, so reading from this stream reaches eof and sets fail|eof bits. + // This test does not cause stream to throw an exception on Linux - I have no idea how to get read() to fail except + // newline translation. std::ifstream iss("tests/data/multiline.xml"); - iss.exceptions(std::ios::eofbit); + iss.exceptions(std::ios::eofbit | std::ios::badbit | std::ios::failbit); try { doc.load(iss); - volatile bool exception_should_be_thrown = false; // to avoid 'controlling expression is constant' warning - CHECK(exception_should_be_thrown); + CHECK(iss.good()); // if the exception was not thrown, stream reading should succeed without errors } catch (const std::ios_base::failure&) { diff --git a/tests/test_xpath.cpp b/tests/test_xpath.cpp index c615f36..fe0a25f 100644 --- a/tests/test_xpath.cpp +++ b/tests/test_xpath.cpp @@ -52,7 +52,7 @@ TEST_XML(xpath_sort_complex, "test"); + load_document_copy(doc, STR("test")); // just some random union order, it should not matter probably? xpath_node_set ns = doc.child(STR("node")).select_nodes(STR("child1 | child2 | child1/@* | . | child2/@* | child2/text()")); @@ -84,7 +84,7 @@ TEST_XML(xpath_sort_children, ""); + load_document_copy(doc, STR("")); xpath_node_set ns = doc.child(STR("node")).select_nodes(STR("child/subchild[@id=1] | child/subchild[@id=2]")); -- cgit v1.2.3