Commit Graph

69 Commits (9cca280a4d0ccf0c08f47a99aa71d1b0e52f8d03)

Author SHA1 Message Date
Florian Albrechtskirchinger 71bdaf5748
Enable overriding test properties and set Unicode test timeouts (#3580)
* CMake: Add TEST_PROPERTIES to json_test_set_test_options()

Allow overriding test properties via json_test_set_test_options().

* CMake: Set timeouts for Unicode tests
2022-07-17 13:43:32 +02:00
Romain Reignier d4daaa897f
Optimize output vector adapter write (#3569)
* Add benchmark for cbor serialization and cbor binary data serialization

* Use std::vector::insert method instead of std::copy in output_vector_adapter::write_characters

This change increases a lot the performance when writing lots of binary data.
2022-07-08 08:12:00 +02:00
Florian Albrechtskirchinger 7d361ec8ef
Add overloads for more key types to ordered_map and fix ordered_map::erase(first, last) with first == last (#3564)
* Add overloads for more key types to ordered_map

Add overloads to accept additional key types defined by type trait
detail::is_usable_as_key_type to ordered_map.
The same key types that can be used with json can now also be used with
ordered_json.

* Fix ordered_map::erase(first, last) with first == last

* Modify element access unit test to also test ordered_json
2022-07-04 19:58:19 +02:00
Florian Albrechtskirchinger 39e27684ea
Use DOCTEST_* compiler macros and suppress pragmas warning (#3550)
Use DOCTEST_* macros in place of predefined compiler macros for compiler
detection and version checks.

The suppression of warning -Wrange-loop-construct in unit-items.cpp
causes GCC<11 to warn about pragmas. Suppressed by adding a version
check.
2022-06-21 16:57:47 +02:00
Qianqian Fang 13730235f2
BJData dimension length can not be string_t::npos, fix #3541 (#3543)
* BJData dimension length can not be string_t::npos, fix #3541

* handle error messages on 32bit machine

* add explanation to why size can not be string_t::npos

* add test cases to 32bit unit test

Co-authored-by: Florian Albrechtskirchinger <falbrechtskirchinger@gmail.com>
2022-06-18 19:12:22 +02:00
Florian Albrechtskirchinger e80945da2c
CI: Enable 32bit unit test (3) (#3532)
* Enable JSON_MultipleHeaders by default

* CI: Add single-header build

* CI: Enable 32bit unit test

* Fix "-Wuseless-cast" warnings

* Remove coverage exclusion

* Fix 32bit test case
2022-06-14 08:54:12 +02:00
Florian Albrechtskirchinger 9c31d54389
Add to_json() for std::vector<bool>::reference (#3534) 2022-06-13 13:21:55 +02:00
Florian Albrechtskirchinger 48a102c2c5
Fix ndarray dimension signedness, fix ndarray length overflow (2); add 32bit unit test (#3523)
* Fix ndarray dimension signness, fix ndarray length overflow, close #3519

* detect size overflow in ubjson and bjdata

* force reformatting

* Fix MSVC compiler warning

* Add value_in_range_of trait

* Use value_in_range_of trait

* Correct 408 parse_errors to out_of_range

* Add 32bit unit test

The test can be enabled by setting JSON_32bitTest=ON.

* Exclude unreachable lines from coverage

Certain lines are unreachable in 64bit builds.

Co-authored-by: Qianqian Fang <fangqq@gmail.com>
2022-06-09 08:22:58 +02:00
Qianqian Fang 046927cc29
Fix nlohmann/json#3513, explain is_ndarray flag (#3514)
* Fix nlohmann/json#3513, explain is_ndarray flag

* add test for ndarray size following H
2022-06-03 08:51:33 +02:00
Florian Albrechtskirchinger 6b97599a27
Fix C++20/gcc-12 issues (Part 2) (#3446)
* Add C++20 3-way comparison operator and fix broken comparisons

Fixes #3207.
Fixes #3409.

* Fix iterators to meet (more) std::ranges requirements

Fixes #3130.
Related discussion: #3408

* Add note about CMake standard version selection to unit tests

Document how CMake chooses which C++ standard version to use when
building tests.

* Update documentation

* CI: add legacy discarded value comparison

* Fix internal linkage errors when building a module
2022-05-29 13:08:06 +02:00
Qianqian Fang ede6667858
Prevent ndarray size vector from recursive use, fix nlohmann/json#3503 (#3505)
* Prevent ndarray size vector from recursive use, fix nlohmann/json#3503

* fix ci error

* complete coverage

* add missing coverage

* fix style issue in added test
2022-05-23 06:07:22 +02:00
Qianqian Fang 41226d0a03
prevent ndarray dimension vector from recusive array, nlohmann/json#3500 (#3502) 2022-05-20 09:41:51 +02:00
Qianqian Fang 93c9e0c703
Discard optimized containers with negative counts in UBJSON/BJData (#3491,#3492,#3490) (#3500)
* Discard optimized containers with negative counts in UBJSON/BJData (#3491,#3492,#3490)

* fix msvc error

* update unit tests for negative sized containers

* use a loop to test 0 ndarray dimension

* throw an error when count is negative, merge CHECK_THROW_AS and _WITH with _WITH_AS
2022-05-18 18:38:15 +02:00
Niels Lohmann 6a7392058e
Complete documentation for 3.11.0 (#3464)
* 👥 update contributor and sponsor list

* 🚧 document BJData format

* 🚧 document BJData format

* 📝 clarified documentation of [json.exception.parse_error.112]

* ✏️ adjust titles

* 📝 add more examples

* 🚨 adjust warnings for index.md files

* 📝 add more examples

* 🔥 remove example for deprecated code

* 📝 add missing enum entry

* 📝 overwork table for binary formats

*  add test to create table for binary formats

* 📝 fix wording in example

* 📝 add more examples

* Update iterators.md (#3481)

*  add check for overloads to linter #3455

* 👥 update contributor list

* 📝 add more examples

* 📝 fix documentation

* 📝 add more examples

* 🎨 fix indentation

* 🔥 remove example for destructor

* 📝 overwork documentation

* Updated BJData documentation, #3464 (#3493)

* update bjdata.md for #3464

* Minor edit

* Fix URL typo

* Add info on demoting ND array to a 1-D optimized array when singleton dimension

Co-authored-by: Chaoqi Zhang <prncoprs@163.com>
Co-authored-by: Qianqian Fang <fangqq@gmail.com>
2022-05-17 13:08:56 +02:00
Qianqian Fang a8a547d7a2
change bjdata ndarray flag to detect negative size, as part of #3475 (#3479)
* change bjdata ndarray flag to detect negative size, fix https://github.com/nlohmann/json/issues/3475

* fix CI error

* fix CI on 32bit windows

* remove platform specific out_of_range error messages

* Incorporate suggestions from @nlohmann and @falbrechtskirchinger

* fix CI errors

* add coverage

* fix sax event order

* fix coverage
2022-05-10 21:13:24 +02:00
Niels Lohmann d6efe672b5
Document fuzzer usage (#3478)
* 📝 document fuzzer usage

* 📝 address review comments
2022-05-09 08:02:41 +02:00
Qianqian Fang b205361d86
Handle invalid BJData optimized type, fix #3461 (#3463)
* Handle invalid BJData optimized type, fix #3461

* Update unit test to handle bjdata optimized array type error
2022-05-01 22:47:06 +02:00
Florian Albrechtskirchinger bdc21ad1a7
Add build step for ICPC (with fixes) (#3465)
* ⬆️ Doctest 2.4.7

* 👷 add CI step for ICPC

* 👷 add CI step for ICPC

* 👷 add CI step for ICPC

* ⬇️ downgrade to Doctest 2.4.6

* 👷 add CI step for ICPC

* 👷 add CI step for ICPC

* 👷 add CI step for ICPC

* 👷 add CI step for ICPC

* 👷 add CI step for ICPC

* 🔇 suppress warning #2196: routine is both "inline" and "noinline"

* Re-enable <filesystem> detection on ICPC

* Limit regression test for #3070 to Clang and GCC >=8.4

* Disable deprecation warnings on ICPC

* Disable regression test for #1647 on ICPC (C++20)

* Fix compilation failure of regression test for #3077 on ICPC

* Disable wstring unit test on ICPC

Fixes:
  error 913: invalid multibyte character sequence

* Add ICPC to README

Co-authored-by: Niels Lohmann <mail@nlohmann.me>
2022-05-01 22:46:45 +02:00
Niels Lohmann b21c345179
Reorganize directories (#3462)
* 🚚 move files
* 🚚 rename doc folder to docs
* 🚚 rename test folder to tests
2022-05-01 09:41:50 +02:00