Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
biojppm committed Apr 4, 2024
1 parent a6d7b2c commit 9c35bc5
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -844,6 +844,12 @@ ryml:
because this may cost up to 10% in processing time.
* `RYML_DEFAULT_CALLBACKS=ON/OFF`. Enable/disable ryml's default
implementation of error and allocation callbacks. Defaults to `ON`.
* `RYML_DEFAULT_CALLBACK_USES_EXCEPTIONS=ON/OFF` - Enable/disable
the same-named macro, which will make the default error handler
provided by ryml throw a `std::runtime_error` exception.
* `RYML_USE_ASSERT` - enable assertions in the code regardless of
build type. This is disabled by default. Failed assertions will
trigger a call to the error callback.
* `RYML_STANDALONE=ON/OFF`. ryml uses
[c4core](https://github.com/biojppm/c4core), a C++ library with low-level
multi-platform utilities for C++. When `RYML_STANDALONE=ON`, c4core is
Expand Down
4 changes: 4 additions & 0 deletions changelog/current.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ Fix major error handling problem reported in [#389](https://github.com/biojppm/r
* std::vector::at(), but the error consists in calling the error
* callback instead of directly raising an exception. */
ConstNodeRef at(csubstr key) const;
/** Likewise, but return a seed node when the key is not found */
ConstNodeRef at(csubstr key);

/** Get a child by position, with error checking; complexity is
* O(pos).
Expand All @@ -33,6 +35,8 @@ Fix major error handling problem reported in [#389](https://github.com/biojppm/r
* std::vector::at(), but the error consists in calling the error
* callback instead of directly raising an exception. */
ConstNodeRef at(size_t pos) const;
/** Likewise, but return a seed node when pos is not found */
ConstNodeRef at(csubstr key);
```
- Added macros and respective cmake options to control error handling:
- `RYML_USE_ASSERT` - enable assertions regardless of build type. This is disabled by default.
Expand Down
4 changes: 1 addition & 3 deletions test/test_case.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,7 @@ void ExpectError::check_assertion(Tree *tree, std::function<void()> fn, Location
#if RYML_USE_ASSERT
ExpectError::do_check(tree, fn, expected_location);
#else
C4_UNUSED(tree);
C4_UNUSED(fn);
C4_UNUSED(expected_location);
ExpectError::check_success(tree, fn); (void)expected_location;
#endif
}

Expand Down
4 changes: 2 additions & 2 deletions test/test_case.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,10 @@ struct ExpectError

static void do_check( std::function<void()> fn, Location expected={}) { do_check(nullptr, fn, expected); }
static void do_check(Tree *tree, std::function<void()> fn, Location expected={});
static void check_success( std::function<void()> fn) { check_success(nullptr, fn); }
static void check_success(Tree *tree, std::function<void()> fn);
static void check_assertion( std::function<void()> fn, Location expected={}) { check_assertion(nullptr, fn, expected); }
static void check_assertion(Tree *tree, std::function<void()> fn, Location expected={});
static void check_success(std::function<void()> fn) { check_success(nullptr, fn); }
static void check_success(Tree *tree, std::function<void()> fn);
};


Expand Down

0 comments on commit 9c35bc5

Please sign in to comment.