summaryrefslogtreecommitdiff
path: root/tests/test_document.cpp
AgeCommit message (Collapse)Author
2017-06-23tests: Add more stream coverage testsArseny Kapoulkine
These new tests test that tellg() can fail when being called the second time, which leads to seekable implementation failing.
2017-06-23tests: Add stream coverage testsArseny Kapoulkine
These tests simulate various error conditions when reading data from streams - seeks failing in seekable streams, underflow throwing an exception causing read to set badbit, etc. This change also adjusts memory thresholds to cause a reliable out of memory during construction of a final buffer for non-seekable streams.
2017-06-22tests: Make using namespace more explicitArseny Kapoulkine
Hiding using namespace in common.hpp is somewhat surprising so remove common.hpp and move using namespace into all .cpp files that need it.
2017-06-22tests: Remove redundant pugi:: qualifierArseny Kapoulkine
Most tests have `using namespace pugi` which makes explicit qualifications unnecessary.
2017-06-22Deprecate xml_document::load(const char*) and xml_node::select_single_nodeArseny Kapoulkine
These functions were deprecated via comments in 1.5 but never got the deprecated attribute; now is the time! Using deprecated functions produces a warning; to silence it, this change moves the relevant tests to a separate translation unit that has deprecation disabled.
2017-06-16tests: Add even more stream coverage testsArseny Kapoulkine
Apparently only narrow character streams had out of memory coverage - fix that and also split this into a separate test.
2017-06-16tests: Add more stream coverage testsArseny Kapoulkine
Cover both char and wchar_t stream loading in a single run instead of using pugi::char_t.
2017-06-16tests: Add more coverage tests for stream loadingArseny Kapoulkine
Cover more failure cases and simplify the streambuf implementation a bit.
2017-06-15tests: Add tests for loading special filesArseny Kapoulkine
New tests try to load a folder as an XML document, and a device. Both are intended to exercise some otherwise non-hittable error paths in load_file implementation.
2017-03-21tests: Do not use unsigned underflow in test codeArseny Kapoulkine
This triggers a runtime error under integer sanitizer
2017-01-30tests: Add more tests for branch coverageArseny Kapoulkine
gcov -b surfaced many lines with partial coverage, where branch is only ever taken or not taken, or one of the expressions in a complex conditional is always either true or false. This change adds a series of tests (mostly focusing on XPath) to reduce the number of partially covered lines.
2016-10-13Add PUGIXML_OVERRIDE to headers of testsPavel Kryukov
2016-07-14tests: Add tests for latin1 detectionArseny Kapoulkine
2016-04-14Remove extra space in an empty tag for format_rawArseny Kapoulkine
When using format_raw the space in the empty tag (<node />) is the only character that does not have to be there; so format_raw almost results in a minimal XML but not quite. It's pretty unlikely that this is crucial for any users - the formatting change should be benign, and it's better to improve format_raw than to add yet another flag. Fixes #87.
2016-01-24Fix whitespace issuesStephan Beyer
Git warns when it finds "whitespace errors". This commit gets rid of these whitespace errors for code and adoc files.
2015-10-25tests: Fix Borland C++ 5.4 compilationArseny Kapoulkine
The tests now compile fine but crash on the first floating-point exception despite our attempts to disable them in main()...
2015-04-12tests: Add more out of memory testsArseny Kapoulkine
Also add tests that verify save_file for absence of FILE leaks.
2015-04-12tests: Add a test that verifies absence of file leaksArseny Kapoulkine
If an out of memory error happens in load_file there's a danger of leaking the FILE object. Since there is a limited supply of the objects we can easily test that the leak does not happen.
2015-04-12tests: Fix some Coverity issuesArseny Kapoulkine
2015-04-11tests: Improve out-of-memory testsArseny Kapoulkine
Previously there was no guarantee that the tests that check for out of memory handling behavior are actually correct - e.g. that they correctly simulate out of memory conditions. Now every simulated out of memory condition has to be "guarded" using CHECK_ALLOC_FAIL. It makes sure that every piece of code that is supposed to cause out-of-memory does so, and that no other code runs out of memory unnoticed.
2015-03-13tests: Fix truncation testArseny Kapoulkine
data/truncation.xml was corrupted at some point and was not actually valid. Fix the file and make the test fail if we can't parse truncation.xml at all.
2015-03-05tests: Move null buffer tests to test_documentArseny Kapoulkine
Remove size=0 test since a better test is already there.
2014-12-13Don't use off64_t/_wfopen on MinGW32 in C++11 modev1.5Arseny Kapoulkine
Unfortunately, standard headers on MinGW32 insist on undefining off64_t and _wfopen extensions if __STRICT_ANSI__ is true (e.g. C++11 mode). This leads to compilation errors since b7a1fec started to use _wfopen in strict mode. That change erroneously checked GCC version - however, the version itself is irrelevant; the actual criteria is whether mingw64 runtime is used. off64_t is not useful on MinGW32 since we only need it to open large files on 64-bit platforms; unfortunately, the lack of _wfopen means we won't be able to support wide-char paths on Windows for MinGW32. Fixes #24.
2014-11-24Use _wfopen and fseeko64 on MinGW in C++11 modeArseny Kapoulkine
Since MinGW 4.5 does not define these functions if __STRICT_ANSI__ is defined (in case of _wfopen it defines it inconsistently between stdio.h and wchar.h) use the baseline functions for MinGW 4.5 and earlier. Fixes #23.
2014-11-24tests: Add a test for load_file with wide Unicode nameArseny Kapoulkine
2014-11-17Rename xml_document::load to load_stringArseny Kapoulkine
This should completely eliminate the confusion between load and load_file. Of course, for compatibility reasons we have to preserve the old variant - it will be deprecated in a future version and subsequently removed.
2014-11-17tests: Don't use /dev/ttyArseny Kapoulkine
The behavior on OSX is different - we don't get a I/O error so the test is useless.
2014-11-01tests: Improve test coverageArseny Kapoulkine
2014-10-23tests: Add more tests for better coverageArseny Kapoulkine
More tests for out-of-memory and other edge conditions git-svn-id: https://pugixml.googlecode.com/svn/trunk@1075 99668b35-9821-0410-8761-19e4c4f06640
2014-10-23tests: Improve test coverageArseny Kapoulkine
git-svn-id: https://pugixml.googlecode.com/svn/trunk@1074 99668b35-9821-0410-8761-19e4c4f06640
2014-10-02tests: Add a test to verify that xml_document object works with any valid ↵Arseny Kapoulkine
pointer alignment git-svn-id: https://pugixml.googlecode.com/svn/trunk@1039 99668b35-9821-0410-8761-19e4c4f06640
2014-04-02tests: Fix Mac OS X compilation.Arseny Kapoulkine
git-svn-id: https://pugixml.googlecode.com/svn/trunk@997 99668b35-9821-0410-8761-19e4c4f06640
2014-02-19tests: Write temporary files to executable folder.Arseny Kapoulkine
Temp folder is the root folder on Windows; writing to the folder may require administrator rights. We can't use current folder for temporaries because tests from different configurations can be running in parallel, but executable folder is always safe since we only run each executable once. git-svn-id: https://pugixml.googlecode.com/svn/trunk@984 99668b35-9821-0410-8761-19e4c4f06640
2014-02-11Implement document fragment parsing.Arseny Kapoulkine
Introduce a notable behavior change in default parsing mode: documents without a document element node are now considered invalid. This is technically a breaking change, however the amount of documents it affects is very small, all parsed data still persists, and lack of this check results in very confusing behavior in a number of cases. In order to be able to parse documents without an element node, a fragment parsing flag is introduced. Parsing a buffer in fragment mode treats the buffer as a fragment of a valid XML. As a consequence, top-level PCDATA is added to the tree; additionally, there are no restrictions on the number of nodes -- so documents without a document element are considered valid. Due to the way parsing works internally, load_buffer_inplace occasionally can not preserve the document contents if it's parsed in a fragment mode. While unfortunate, this problem is fundamental; since the use case is relatively obscure, hopefully documenting this shortcoming will be enough. git-svn-id: https://pugixml.googlecode.com/svn/trunk@980 99668b35-9821-0410-8761-19e4c4f06640
2014-02-10Fix clang build.Arseny Kapoulkine
git-svn-id: https://pugixml.googlecode.com/svn/trunk@978 99668b35-9821-0410-8761-19e4c4f06640
2014-02-10Use a null-terminated buffer for parsing as often as possible.Arseny Kapoulkine
Parsing used to work on a non null-terminated buffer, inserting a fake null terminator to increase performance. This makes it impossible to implement fragment parsing that preserves PCDATA contents (as witnessed by some tests for boundary conditions that actually depended on this behavior). Since almost all uses result in us allocating an internal buffer anyway, the new policy is to make sure all buffers that are allocated by pugixml are null-terminated - the only exception now is external calls to load_buffer_inplace that don't trigger encoding conversion. git-svn-id: https://pugixml.googlecode.com/svn/trunk@977 99668b35-9821-0410-8761-19e4c4f06640
2012-10-31tests: Remove 'con' loading from tests since it stopped working under ↵arseny.kapoulkine@gmail.com
Windows 8... git-svn-id: http://pugixml.googlecode.com/svn/trunk@921 99668b35-9821-0410-8761-19e4c4f06640
2012-03-23tests: Added text/binary save_file testsarseny.kapoulkine@gmail.com
git-svn-id: http://pugixml.googlecode.com/svn/trunk@884 99668b35-9821-0410-8761-19e4c4f06640
2012-03-06tests: Android compilation fixesarseny.kapoulkine@gmail.com
git-svn-id: http://pugixml.googlecode.com/svn/trunk@846 99668b35-9821-0410-8761-19e4c4f06640
2012-03-06tests: Use mkstemp on Unix and QNX (BlackBerry) to avoid tmpnam deprecation ↵arseny.kapoulkine@gmail.com
warning git-svn-id: http://pugixml.googlecode.com/svn/trunk@843 99668b35-9821-0410-8761-19e4c4f06640
2012-03-06tests: Fixed compilation errors for BadaSDKarseny.kapoulkine@gmail.com
git-svn-id: http://pugixml.googlecode.com/svn/trunk@839 99668b35-9821-0410-8761-19e4c4f06640
2012-02-19tests: Minor fixes for WinCE compilationarseny.kapoulkine@gmail.com
git-svn-id: http://pugixml.googlecode.com/svn/trunk@834 99668b35-9821-0410-8761-19e4c4f06640
2011-12-20Introduced encoding_latin1 support (conversion on loading, conversion on ↵arseny.kapoulkine
saving, encoding name in declaration in document::save) git-svn-id: http://pugixml.googlecode.com/svn/trunk@829 99668b35-9821-0410-8761-19e4c4f06640
2011-07-19tests: Added tests for non-seekable streamsarseny.kapoulkine
git-svn-id: http://pugixml.googlecode.com/svn/trunk@810 99668b35-9821-0410-8761-19e4c4f06640
2010-12-19Enabled many additional GCC warnings (most notably -Wshadow and ↵arseny.kapoulkine
-Wold-style-cast), fixed the code accordingly git-svn-id: http://pugixml.googlecode.com/svn/trunk@800 99668b35-9821-0410-8761-19e4c4f06640
2010-10-31tests: Added document reset-self testarseny.kapoulkine
git-svn-id: http://pugixml.googlecode.com/svn/trunk@787 99668b35-9821-0410-8761-19e4c4f06640
2010-10-31Added xml_document::reset() function with document parameterarseny.kapoulkine
git-svn-id: http://pugixml.googlecode.com/svn/trunk@786 99668b35-9821-0410-8761-19e4c4f06640
2010-10-26Added xml_document::reset, added append/prepend/insert child overloads for ↵arseny.kapoulkine
elements (with explicit name) git-svn-id: http://pugixml.googlecode.com/svn/trunk@779 99668b35-9821-0410-8761-19e4c4f06640
2010-10-22tests: Fixed WCHAR mode compilationarseny.kapoulkine
git-svn-id: http://pugixml.googlecode.com/svn/trunk@774 99668b35-9821-0410-8761-19e4c4f06640
2010-10-18Added xml_document::document_element functionarseny.kapoulkine
git-svn-id: http://pugixml.googlecode.com/svn/trunk@768 99668b35-9821-0410-8761-19e4c4f06640