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

573 Commits

Author SHA1 Message Date
Arseny Kapoulkine
00ef791078 fuzz: Use libFuzzer instead of afl-fuzz
This allows us to have faster fuzz cycles since the fuzzer is in-process.
2017-02-09 07:36:32 -08:00
Arseny Kapoulkine
e748f435e5 tests: Increase the number of translate calls
This should make the test fail on a 32-bit target.
2017-02-09 07:36:32 -08:00
Arseny Kapoulkine
4bab082a27 tests: Fix clang build 2017-02-09 07:36:32 -08:00
Arseny Kapoulkine
ba39838ab5 tests: Add more XPath out of memory tests 2017-02-09 07:36:31 -08:00
Arseny Kapoulkine
10676b6b85 tests: Add more XPath sorting tests
Cover empty node case - no XPath query can result in that but it's
possible to create a node set with empty nodes manually.
2017-02-05 21:12:55 -08:00
Arseny Kapoulkine
faadd460c4 tests: Add more out of memory tests for XPath evaluation 2017-02-02 08:57:02 -08:00
Arseny Kapoulkine
c28ff128d8 tests: Add more embed_pcdata tests 2017-02-02 08:40:34 -08:00
Arseny Kapoulkine
f9f1c86716 tests: Improve parsing coverage
Add tests for PI erroring exactly at the buffer boundary with
non-zero-terminated buffers (so we have to clear the last character
which changes the parsing flow slightly) and a test that makes sure
parse_embed_pcdata works properly with XML fragments where PCDATA can be
at the root level but can't be embedded into the document node.
2017-02-01 21:07:46 -08:00
Arseny Kapoulkine
e56686f1e5 tests: Remove redundant coverage test
The only point was to try to test all paths where we can run out of
memory while decoding something. It seems like it may be impossible to
actually do this given that we can't run all paths as wchar_t size
detection is done at runtime...
2017-02-01 20:21:14 -08:00
Arseny Kapoulkine
1a3e92a7cc tests: Add more tests to increase coverage
This change adds more thorough tests for attribute conversion as well as
some assorted tests that fix gaps in coverage.
2017-01-31 20:40:50 -08:00
Arseny Kapoulkine
094a0c8ebe tests: Add compact hash table reserve test
This makes sure all .reserve calls failure paths are covered. These
tests don't explicitly test if reserve is present on all paths - this is
much harder to test since not all modifications require reserve to be
called, so we'll have to rely on a combination of automated testing and
sanity checking for this.

Also add more parsing out of memory coverage tests.
2017-01-31 19:19:04 -08:00
Arseny Kapoulkine
41fb880bf0 tests: Add coverage tests for encoding detection
Enumerate successfull cases and also cases where the detection stops
half-way and results in a different detected encoding.
2017-01-31 07:50:39 -08:00
Arseny Kapoulkine
ef64bef5c3 tests: More XPath coverage tests 2017-01-31 00:35:15 -08:00
Arseny Kapoulkine
6ffd2ffc41 tests: Add more DOM coverage tests
Add tests for various corner cases of DOM inspection and modification
routines.
2017-01-31 00:10:20 -08:00
Arseny Kapoulkine
a1bc15c8d5 tests: Add more coverage tests
Expand out of memory coverage during XPath parsing and evaluation and
add some other small tests.
2017-01-30 23:52:32 -08:00
Arseny Kapoulkine
60d5688a87 tests: Make predicate out-of-memory test less aggressive
Currently this test has very large runtime and relies on the fact that
the first memory allocation error causes the test to terminate. This
does not work with new behavior of running the query through and
reporting the error at the end, so make the runtime reasonable but still
generate enough memory to blow past the budget.
2017-01-30 22:27:48 -08:00
Arseny Kapoulkine
02cee98492 tests: Add more tests for branch coverage
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.
2017-01-30 21:58:48 -08:00
Arseny Kapoulkine
cac1d8ad9f tests: Add an error propagation test for XPath
This test is supposed to test error coverage in different expressions
that are nested in other expressions to reduce the number of never-taken
branches in tests (and make sure we aren't missing any).
2017-01-30 11:51:07 -08:00
Arseny Kapoulkine
8aa8e11ba6 tests: Add query out of memory test 2017-01-29 21:53:40 -08:00
Arseny Kapoulkine
86ed1cf3b9 scripts: Move archive.py from tests 2016-11-27 17:55:41 -08:00
Arseny Kapoulkine
d2deb420bc Fix archive script to set timestamps properly for .tar.gz
By default they are set to Jan 1 1970 which breaks homebrew.

Fixes #124.
2016-11-27 12:09:12 -08:00
Arseny Kapoulkine
5115db7409 tests: Fix unused variable warning in some compilers
The variable is being assigned to but never read when exceptions are
disabled.
2016-11-19 00:19:29 -08:00
Arseny Kapoulkine
1e23402eb2 Change status_end_element_mismatch to point to closing tag name
Previously the error offset pointed to the first mismatching character, which
can be confusing especially if the start tag name is a prefix of the end tag
name. Instead, move the offset to the first character of the name - that way
it should be more obvious that the problem is that the entire name mismatches.

Fixes #112.
2016-11-13 16:59:14 -08:00
Arseny Kapoulkine
5ca7e7cffc Rewrite archive script into Python
Perl version needed Archive::Zip that for some reason is not installed on WSL by
default. Use this as an opportunity to remove the last Perl script.
2016-11-13 16:52:38 -08:00
Arseny Kapoulkine
c5223be434 tests: Fix MSVC warnings 2016-11-09 21:42:56 -08:00
Arseny Kapoulkine
2d47cde5d6 tests: Add a generalized write-roundtrip test
This test tests two important invariants:

- Every combination of write flags has to result in a valid document
- Parsing that document and saving the result has to result in identical output

We don't test all flags since parse_no_escapes can intentionally result in
malformed documents and other flags aren't relevant for node output.

Also note that we test both no-whitespace and whitespace version to make sure
we don't have unnecessary whitespace added during formatting.
2016-11-09 20:12:25 -08:00
Arseny Kapoulkine
1649b2e6b8 tests: Add a test for format_no_empty_element_tags 2016-11-09 09:12:36 -08:00
Arseny Kapoulkine
c75e3c45e5 Update version to 1.8 everywhere 2016-11-09 09:02:44 -08:00
Arseny Kapoulkine
70f57fab6d tests: Don't use ranged for loop in move tests
Some compilers support move semantics but don't support ranged for.
2016-11-06 12:14:58 -08:00
Arseny Kapoulkine
aa117cce42 Refactor move semantics support detection
Do it in one place and set PUGIXML_HAS_MOVE if it's available.
2016-11-06 11:49:10 -08:00
Pavel Kryukov
c7c7349cb7 Add PUGIXML_OVERRIDE to headers of tests 2016-10-13 01:36:12 +03:00
Arseny Kapoulkine
5b102d108d tests: Fix clang warning 2016-07-15 18:53:59 -05:00
Arseny Kapoulkine
525b2fe5c3 tests: Add tests for latin1 detection 2016-07-14 23:04:17 -07:00
Arseny Kapoulkine
2e0ed8284b Remove extra space in an empty tag for format_raw
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-04-14 00:30:24 -07:00
Arseny Kapoulkine
d2e72ee05a tests: Add tests for long setters 2016-02-02 08:49:32 -08:00
Stephan Beyer
fc9073289f test_parse.cpp: add newline to last line
This is necessary in order to comply with the C++03 standard.
2016-01-24 19:47:06 +01:00
Stephan Beyer
f7aa65db8a Fix whitespace issues
Git warns when it finds "whitespace errors". This commit gets
rid of these whitespace errors for code and adoc files.
2016-01-24 14:05:44 +01:00
Arseny Kapoulkine
fc6c8633dd tests: Add test for parse_embed_pcdata 2016-01-12 20:16:29 -08:00
Arseny Kapoulkine
94c08f27c6 tests: Fix Borland C++ 5.4 compilation
The tests now compile fine but crash on the first floating-point exception
despite our attempts to disable them in main()...
2015-10-25 13:44:26 -07:00
Arseny Kapoulkine
fd605bc9a7 tests: Fix GCC warning
Fix "this decimal constant is unsigned only in ISO C90".
2015-10-17 12:20:21 -07:00
Arseny Kapoulkine
0e09571f21 Fix integer overflow detection with leading zeros
Since they don't contribute to the resulting value just skip them before
parsing. This matches the behavior of strtol/strtoll and results in more
intuitive behavior.
2015-10-17 10:33:50 -07:00
Arseny Kapoulkine
537aea56c6 tests: Fix version check :) 2015-10-10 13:07:53 -07:00
Arseny Kapoulkine
3e9cf53ea7 tests: Add a test for empty xpath_query ctor 2015-10-09 20:53:02 -07:00
Arseny Kapoulkine
6e5163ba3e tests: Add a copy of header-only test
This makes sure we get linking errors whenever a symbol is not marked as inline
in header-only mode.
2015-10-06 07:26:24 -07:00
Arseny Kapoulkine
3229e67712 Fix parsing of integers that start with +
This matches the format strtol supports.
2015-09-21 00:35:57 -07:00
Arseny Kapoulkine
5b86a8f612 tests: Add tests for integer overflow during conversion
These tests are only testing attribute as_int in hopes that xml_text uses the
same underlying implementation (which it does).
2015-09-20 10:48:30 -07:00
Arseny Kapoulkine
234c2f3657 tests: Convert several files to Unix line endings
They were still using Windows EOL by mistake
2015-09-19 00:14:18 -07:00
Arseny Kapoulkine
e8fdd1303c tests: Fix test allocator to provide fundamental alignment
Previously test allocator only guaranteed alignment enough for a pointer.

On some platforms (e.g. SPARC) double has to be aligned to 8 bytes but pointers
can have a size of 4 bytes. This commit increases allocation header to fix that.

In practical terms the allocation header is now always 8 bytes.
2015-07-25 17:04:17 -04:00
Arseny Kapoulkine
a562bf6d3c tests: Only enable page heap on x86/x64
This fixes tests in PUGIXML_NO_XPATH mode on SPARC64 (#48).

SPARC does not allow unaligned accesses - e.g. you can't read an unaligned int.
Normally pugixml does not perform unaligned integer/pointer accesses, but page
heap can allocate blocks that are not aligned so that we can detect a single-
byte read/write overrun.

Additionally, the hardcoded page size we're currently using is really system
specific - on SPARC the page size can be 8 Kb instead of 4 Kb so mprotect can
fail.
2015-07-25 14:19:08 -04:00
Arseny Kapoulkine
97afc16ef2 tests: Add newline at the end of file 2015-05-22 20:20:03 -07:00
Arseny Kapoulkine
fc1dcab79d tests: Fix MSVC6 compilation 2015-05-22 08:43:36 -07:00
Arseny Kapoulkine
e2358e5e3b tests: Split fp roundtrip test into float and double 2015-05-20 08:05:43 -07:00
Arseny Kapoulkine
f828eae3ea Implement xml_node::attribute with a hint
Extra argument 'hint' is used to start the attribute lookup; if the attribute
is not found the lookup is restarted from the beginning of the attriubte list.

This allows to optimize attribute lookups if you need to get many attributes
from the node and can make assumptions about the likely ordering. The code is
correct regardless of the order, but it is faster than using vanilla lookups
if the order matches the calling order.

Fixes #30.
2015-05-14 08:04:06 -07:00
Arseny Kapoulkine
01f627a4d7 tests: Fix address sanitizer detection for GCC 2015-05-12 21:49:44 -07:00
Arseny Kapoulkine
59ce480f96 Add Visual Studio 2015 to AppVeyor 2015-05-12 20:55:59 -07:00
Arseny Kapoulkine
7342c5ed8c tests: Disable page allocator if address sanitizer is active
Address sanitizer can detect underflows so we don't really need the custom
allocator.

Additionally, custom allocator can return memory that is not pointer-aligned;
this causes undefined behavior sanitizer to complain.
2015-05-12 20:16:51 -07:00
Arseny Kapoulkine
9f7994ed71 tests: Fix clang 3.7 warning
Work around -Wself-move using ref-deref.
2015-05-12 20:02:53 -07:00
Arseny Kapoulkine
cff35dfa31 tests: Fix MSVC6 compatibility
Apply the usual workaround for for scoping issues. Also fix integer conversion
warning for BorlandC.
2015-05-03 17:58:20 -07:00
Arseny Kapoulkine
19d43d39fc tests: Add one more page reclamation test 2015-05-02 09:45:26 -07:00
Arseny Kapoulkine
dede617d9f tests: Fix spurious failures in compact mode
The memory_large_allocations test sometimes classified hash allocations
as page allocations since hash table could reach 512 entries.
2015-04-29 09:21:04 -07:00
Arseny Kapoulkine
3643b505a6 Fix node_pi memory leak 2015-04-22 08:38:52 -07:00
Arseny Kapoulkine
52bcb4ecd6 tests: Adjust allocation thresholds to fix tests 2015-04-21 21:35:54 -07:00
Arseny Kapoulkine
f9983ea2ed Merge branch 'master' into compact 2015-04-21 21:27:44 -07:00
Arseny Kapoulkine
a6cc636a6b tests: Fix MSVC warnings 2015-04-21 21:07:58 -07:00
Arseny Kapoulkine
4eadece45f tests: Add move semantics tests
Also test ranged for and copying big xpath_variable_set objects (to make
sure we actually handle hash collisions properly)
2015-04-21 19:44:19 -07:00
Arseny Kapoulkine
cbf3807ad4 Implement copy ctor/assignment for xpath_variable_set
xpath_variable_set is essentially an associative container; it's about time it
became copyable.

Implementation is slightly tricky due to out of memory handling. Both copy ctor
and assignment operator have strong exception guarantee (even if exceptions are
disabled! which translates to "roll back on allocation errors").
2015-04-15 23:22:31 -07:00
Arseny Kapoulkine
70a78b2fa5 tests: Fix Linux build 2015-04-15 22:11:13 -07:00
Arseny Kapoulkine
bb3aee447b tests: Use malloc for OSX/Linux page heap
Switch to malloc and manually aligning the pointer to the page boundary.

mmap is much slower than malloc; this change makes tests ~4x faster.
2015-04-15 21:44:52 -07:00
Arseny Kapoulkine
5158ee903b Fix xpath_node_set assignment to provide strong exception guarantee
Since the type of the set was updated before assignment, assigning in
out-of-memory condition could change the type to not match the content.
2015-04-14 19:23:36 -07:00
Arseny Kapoulkine
2a3435274f Refactor format_indent_attributes implementation
Fix code style and revert redundant parameters/whitespace changes.

Also remove format_each_attribute_on_new_line - we're only introducing one
extra formatting flag. The flag implies format_indent but does not include its
bitmask.

Also add a few more tests.

Fixes #14.
2015-04-13 21:49:08 -07:00
Arseny Kapoulkine
950693be7f Merge branch 'AlignAttributesEachOnSeparateLine' of git://github.com/halex2005/pugixml into indent_attributes 2015-04-13 20:56:18 -07:00
Arseny Kapoulkine
cb786665d4 tests: Add PUGIXML_COMPACT to AppVeyor 2015-04-13 20:36:04 -07:00
Arseny Kapoulkine
ed2c822643 Merge branch 'master' into compact 2015-04-13 20:35:26 -07:00
Arseny Kapoulkine
1c4098a7d9 Remove all files for the Jamplus-based build system
End of an era.

Make can be used for regular development (Linux/OSX), documentation building
and release packaging.
CMake can be used for regular development (Windows); it's also used by some
Linux distributions.

Continuous integration is now performed by Travis CI and AppVeyor.
2015-04-13 20:30:14 -07:00
Arseny Kapoulkine
218ddd0376 Add AppVeyor build scripts 2015-04-13 20:03:49 -07:00
halex2005
5d66ae9fb9 add tests for aligning each attribute on next line 2015-04-14 00:56:42 +05:00
Arseny Kapoulkine
054b0b447e Merge branch 'master' into compact 2015-04-12 22:09:45 -07:00
Arseny Kapoulkine
9539c488c2 Fix unused variable warning
Also fix test in wchar_t mode.
2015-04-12 22:06:17 -07:00
Arseny Kapoulkine
f04b56e178 Permit custom allocation function to throw
Ensure that all the necessary cleanup is performed in case the allocation fails
with an exception - files are closed, buffers are reclaimed, etc.

Any test that triggers a simulated out-of-memory condition is ran once again
with a throwing allocation function. Unobserved std::bad_alloc count as test
failures and require CHECK_ALLOC_FAIL macro.

Fixes #17.
2015-04-12 21:46:48 -07:00
Arseny Kapoulkine
5edeaf6765 tests: Add more out of memory tests
Also add tests that verify save_file for absence of FILE leaks.
2015-04-12 21:27:12 -07:00
Arseny Kapoulkine
6c11a0c693 Fix compilation and tests after merge. 2015-04-12 03:14:08 -07:00
Arseny Kapoulkine
a19da1c246 Merge branch 'master' into compact 2015-04-12 03:05:58 -07:00
Arseny Kapoulkine
a0d065cd22 Implment copyless copy for attributes
Previously attributes that were copied with their node used string sharing,
but standalone attributes that were copied using xml_node::*_copy(xml_attribute)
were not.
2015-04-12 03:03:56 -07:00
Arseny Kapoulkine
c5d07e2c28 tests: Add a test that verifies absence of file leaks
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-12 02:34:48 -07:00
Arseny Kapoulkine
2537cccad3 tests: Fix some Coverity issues 2015-04-12 02:17:20 -07:00
Arseny Kapoulkine
3da7d68617 Fix Travis CI build. 2015-04-11 22:52:41 -07:00
Arseny Kapoulkine
4e004176ba tests: Improve out-of-memory tests
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-04-11 22:46:08 -07:00
Arseny Kapoulkine
37467c13bf tests: Add a test for throwing from xml_writer::write
We currently don't allocate/modify any state so there are no issues with this.
2015-04-11 22:44:42 -07:00
Arseny Kapoulkine
814443b147 Fix exception type for out-of-memory for XPath variables
When parsing XPath variables, we need to perform a heap allocation; if it
fails, an xpath_exception instead of bad_alloc used to be thrown.

Now we throw the exception of a correct type so that xpath_exception means
'parsing error'.
2015-04-11 22:40:30 -07:00
Arseny Kapoulkine
03ea04c32a tests: Use char_t instead of wchar_t 2015-04-11 00:33:35 -07:00
Arseny Kapoulkine
29fef9aca2 tests: Add more out of memory tests
This provides more coverage for #17.
2015-04-11 00:16:39 -07:00
Arseny Kapoulkine
e90d2ac8ba Merge branch 'master' into compact 2015-04-10 22:26:57 -07:00
Arseny Kapoulkine
f1d1534210 Fix archive packaging
Base directory is now using target basename.
2015-04-10 20:45:07 -07:00
Arseny Kapoulkine
5959a17967 tests: Final test fix for CW 2015-03-21 17:09:42 -07:00
Arseny Kapoulkine
250b690a54 tests: Work around fp issues in various runtime libraries
Disable/change some tests for some compilers; use binary float comparison
for early MSVC versions.
2015-03-21 01:05:31 -07:00
Arseny Kapoulkine
ce974094ac tests: Fix test compilation
Rename PAGE_SIZE to page_size to avoid define conflict with Android SDK.
Minor fixes in several tests.
2015-03-21 00:14:53 -07:00
Arseny Kapoulkine
86410cd696 tests: Fix tests in wchar mode 2015-03-18 21:30:30 -07:00
Arseny Kapoulkine
e68048518e Update version to 1.6 2015-03-18 21:20:40 -07:00
Arseny Kapoulkine
5f996eba6d Do not emit surrounding whitespace for text nodes
Previously we omitted extra whitespace for single PCDATA/CDATA children, but in
mixed content there was extra indentation before/after text nodes.

One of the problems with that is that the text that you saved is not exactly
the same as the parsing result using default flags (parse_trim_pcdata helps).

Another problem is that parse-format cycles do not have a fixed point for mixed
content - the result expands indefinitely. Some XML libraries, like Python
minidom, have the same issue, but this is definitely a problem.

Pretty-printing mixed content is hard. It seems that the only other sensible
choice is to switch mixed content nodes to raw formatting. In a way the code in
this change is a weaker version of that - it removes indentation around text
nodes but still keeps it around element siblings/children.

Thus we can switch to mixed-raw formatting at some point later, which will be
a superset of the current behavior.

To do this we have to either switch at the first text node (.NET XmlDocument
does that), or scan the children of each element for a possible text node and
switch before we output the first child.

The former behavior seems non-intuitive (and a bit broken); unfortunately, the
latter behavior can cost up to 20% of the output time for trees *without* mixed
content.

Fixes #13.
2015-03-18 09:59:17 -07:00
Arseny Kapoulkine
51da129b50 tests: Fix truncation test
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-13 22:13:10 -07:00
Arseny Kapoulkine
6457f09412 Merge branch 'master' into compact 2015-03-13 08:12:46 -07:00
Arseny Kapoulkine
15fba1debc tests: Add support for afl-fuzz
With the current setup it successfully finds the (fixed) DOCTYPE buffer overrun
in ~50 minutes (on a single core).
2015-03-13 00:18:30 -07:00
Arseny Kapoulkine
0542b1869b Fix buffer overrun when parsing comments inside DOCTYPE 2015-03-12 20:21:59 -07:00
Arseny Kapoulkine
f81d7cc018 Merge branch 'master' into compact 2015-03-10 20:44:06 -07:00
Arseny Kapoulkine
604861e520 Escape ?> sequence in PI value during printing
This prevents malformed PI value from breaking the document structure.
2015-03-10 09:03:22 -07:00
Arseny Kapoulkine
12e137d12f tests: Move null buffer tests to test_document
Remove size=0 test since a better test is already there.
2015-03-05 11:46:34 -08:00
Arseny Kapoulkine
9749920c82 Refactor contents=0 behavior
Also change the error code to status_io_error
2015-03-05 11:35:39 -08:00
Arseny Kapoulkine
7ae7344256 Merge branch 'master' of https://github.com/mloy/pugixml into mloy-master 2015-03-05 10:09:54 -08:00
Arseny Kapoulkine
5a848de085 tests: Fix XPath string comparison
Also add new tests for translate. These are technically redundant since other
tests would catch the bug with the fixed comparison, but more tests is better.
2015-03-04 10:44:08 -08:00
Arseny Kapoulkine
ee4e2b8669 tests: Implement page heap for OSX/Linux
Align allocations to right end of page boundary to catch buffer overruns,
instead of unmapping on deallocations mark the page as no-access to guarantee
a page fault on use-after-free.
2015-03-01 20:57:22 -08:00
Arseny Kapoulkine
7835302297 tests: Fix tests for wchar mode 2015-02-12 08:54:44 -08:00
Arseny Kapoulkine
e94552c9ca DOCTYPE parsing is now stackless
This prevents malformed input XML with very deeply recursive DOCTYPE sections
from crashing the parser.

Fixes #29.
2015-02-12 08:12:12 -08:00
Arseny Kapoulkine
650a4c6cca Use string::append in implementations of xml_writer
The current code is not optimal; since users actually read samples/tests
change them to use faster (and shorter!) code.
2015-01-24 08:20:42 -08:00
Arseny Kapoulkine
3181a305ed tests: Fix MSVC 2008 compilation warning
Also include math.h to fix issues on some compilers.
2015-01-17 18:40:09 -08:00
Arseny Kapoulkine
617f302808 tests: Use Git instead of Subversion in autotest 2015-01-17 18:39:29 -08:00
Arseny Kapoulkine
e5ecbd63ce Merge branch 'master' into compact 2015-01-16 21:48:50 -08:00
Arseny Kapoulkine
d454013cff tests: Add tests for fp roundtrip
We test min/max and several different mantissas for the entire exponent range
for both float and double.

It's not clear whether all supported compilers provide an implementation of
sprintf/strtod that supports roundtripping so we may need to disable some of
these tests in the future.
2015-01-16 21:43:28 -08:00
Arseny Kapoulkine
f9ee391233 tests: Add coverage tests for new float setters
These only do basic testing to make sure the paths are covered and trivial
values work.
2015-01-16 21:42:35 -08:00
Arseny Kapoulkine
550ab4b635 Merge pull request #27 from sdoiel61/master
Make float/double round-trip

This change also adds xml_text::set and xml_attribute::set_value overloads for float so that float is only printed using just enough digits to represent float, instead of enough digits to represent double.
2015-01-16 20:54:58 -08:00
Steve Doiel
cf72c20ca1 Increase precision on large number test 2015-01-16 16:14:59 -08:00
Arseny Kapoulkine
f3e42969a5 Simplify header-only mode usage
It's sufficient to define PUGIXML_HEADER_ONLY anywhere now, source is included
automatically.

This is a second attempt; this time it includes a workaround for QMake bug
that caused it to generate incorrect Makefile.
2015-01-09 23:22:57 -08:00
Arseny Kapoulkine
ff16dbdd4c Don't use off64_t/_wfopen on MinGW32 in C++11 mode
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-12-13 20:34:10 -08:00
Arseny Kapoulkine
93c3ab4649 Merge branch 'master' into compact 2014-11-27 00:25:16 -08:00
Arseny Kapoulkine
b7a1feccf7 Use _wfopen and fseeko64 on MinGW in C++11 mode
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-24 20:49:12 -08:00
Arseny Kapoulkine
3e1ae89cf6 tests: Add a test for load_file with wide Unicode name 2014-11-24 18:27:54 -08:00
Arseny Kapoulkine
db8df4a566 Merge branch 'master' into compact 2014-11-20 23:47:16 -08:00
Arseny Kapoulkine
125aa55061 Fix node_declaration copying with empty name
node_copy_string relied on the fact that target node had an empty name and
value. Normally this is a safe assumption (and a good one to make since it
makes copying faster), however it was not checked and there was one case when
it did not hold.

Since we're reusing the logic for inserting nodes, newly inserted declaration
nodes had the name set automatically to xml, which in our case violates the
assumption and is counter-productive since we'll override the name right after
setting it.

For now the best solution is to do the same insertion manually - that results
in some code duplication that we can refactor later (same logic is partially
shared by _move variants anyway so on a level duplicating is not that bad).
2014-11-20 23:39:40 -08:00
Arseny Kapoulkine
417048d8cb tests: Fix tests on various compilers
Some compilers don't handle NaNs properly.
Some compilers don't implement fmod in a IEEE-compatible way.
Some compilers have exception handling codegen bugs (DMC...).
2014-11-19 16:34:57 -08:00
Arseny Kapoulkine
3c048bbb5e tests: Fix version test 2014-11-17 22:45:38 -08:00
Arseny Kapoulkine
e9956ae3a6 Rename xml_document::load to load_string
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-17 19:52:23 -08:00
Arseny Kapoulkine
79ed320f89 tests: Don't use /dev/tty
The behavior on OSX is different - we don't get a I/O error so the test is
useless.
2014-11-17 08:35:34 -08:00
Arseny Kapoulkine
c74dc33604 Merge branch 'master' into compact 2014-11-07 21:02:44 +01:00
Arseny Kapoulkine
50bfdb1856 tests: Fix all tests for compact mode
Memory allocation behavior is different in compact mode so tests that rely
on current behavior have to be adjusted.
2014-11-06 09:59:07 +01:00
Arseny Kapoulkine
aa1a61c59f Fix xml_node::offset_debug for corner cases
Computed offsets for documents with nodes that were added using append_buffer
or newly appended nodes without name/value information were invalid.
2014-11-05 09:32:52 +01:00
Matthias Loy
1912894f53 :Merge remote-tracking branch 'upstream/master' 2014-11-03 20:23:35 +01:00
Arseny Kapoulkine
97a515f873 tests: Add more XPath mod tests 2014-11-03 07:50:00 +01:00
Arseny Kapoulkine
e9948b4b05 Fix undefined behavior while calling memcpy
Calling memcpy(x, 0, 0) is technically undefined (although it should usually
be a no-op).
2014-11-02 09:30:56 +01:00
Arseny Kapoulkine
f68a320a02 tests: Improve test coverage 2014-11-01 11:45:13 +01:00
mloy
837ced350c load_buffer_impl always checks if buffer is valid pointer and size > 0
added some tests to force invalid buffer and size = 0
2014-10-30 14:30:05 +01:00
Arseny Kapoulkine
6229138d80 Optimize node printing by using raw pointers
This lets us do fewer null pointer checks (making printing 2% faster with -O3)
and removes a lot of function calls (making printing 20% faster with -O0).
2014-10-27 22:29:14 -07:00
Arseny Kapoulkine
c64d4820b1 XPath: Optimize [position()=expr] and [last()]
To get more benefits from constant predicate/filter optimization we rewrite
[position()=expr] predicates into [expr] for numeric expressions. Right now
the rewrite is only for entire expressions - it may be beneficial to split
complex expressions like [position()=constant and expr] into [constant][expr]
but that is more complicated.

last() does not depend on the node set contents so is "constant" as far as
our optimization is concerned so we can evaluate it once.
2014-10-27 18:50:09 -07:00
Arseny Kapoulkine
d5e29292c6 XPath: Optimize constant filters/predicates
If a filter/predicate expression is a constant, we don't need to evaluate it
for every nodeset element - we can evaluate it once and pick the right element
or keep/discard the entire collection.

If the expression is 1, we can early out on first node when evaluating the
node set - queries like following::item[1] are now significantly faster.

Additionally this change refactors filters/predicates to have additional
metadata describing the expression type in _test field that is filled during
optimization.

Note that predicate_constant selection right now is very simple (but captures
most common use cases except for maybe [last()]).
2014-10-26 09:37:18 -07:00
Arseny Kapoulkine
f31c14e1fd tests: Remove git2svn helper script! 2014-10-26 02:22:27 -07:00
Arseny Kapoulkine
0e59ea8234 tests: Add a way for tests to verify allocation failure
git-svn-id: https://pugixml.googlecode.com/svn/trunk@1081 99668b35-9821-0410-8761-19e4c4f06640
2014-10-26 03:46:28 +00:00
Arseny Kapoulkine
0b7964917c Fix node copying for some out of memory cases
A page can fail to allocate during attribute creation; this case was not
previously handled.

git-svn-id: https://pugixml.googlecode.com/svn/trunk@1080 99668b35-9821-0410-8761-19e4c4f06640
2014-10-25 16:37:16 +00:00
Arseny Kapoulkine
7b74531c1b tests: Fix test failure in PUGIXML_WCHAR_MODE
git-svn-id: https://pugixml.googlecode.com/svn/trunk@1077 99668b35-9821-0410-8761-19e4c4f06640
2014-10-24 01:37:27 +00:00
Arseny Kapoulkine
546997683a tests: Add even more coverage tests
Also fix MSVC6 compilation (make convertions to function pointers explicit).

git-svn-id: https://pugixml.googlecode.com/svn/trunk@1076 99668b35-9821-0410-8761-19e4c4f06640
2014-10-24 01:17:57 +00:00
Arseny Kapoulkine
903db8682a tests: Add more tests for better coverage
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-23 07:41:07 +00:00
Arseny Kapoulkine
bbd75fda46 tests: Improve test coverage
git-svn-id: https://pugixml.googlecode.com/svn/trunk@1074 99668b35-9821-0410-8761-19e4c4f06640
2014-10-23 05:46:44 +00:00
Arseny Kapoulkine
3c92704c19 tests: Fix PUGIXML_WCHAR_MODE compilation
git-svn-id: https://pugixml.googlecode.com/svn/trunk@1071 99668b35-9821-0410-8761-19e4c4f06640
2014-10-21 03:38:30 +00:00