Skip to content

Commit

Permalink
Add assertion_info.location
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremy-rifkin committed Mar 14, 2024
1 parent 4e46fd7 commit 4ca0370
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,15 @@ Debug Assertion failed at demo.cpp:194: void foo::baz(): Internal error with foo
Debug Assertion failed at demo.cpp:194: void foo::baz(): Internal error with foobars
```

`assertion_info.location()`:

> [!NOTE]
> Path processing will be performed according to the path mode

```
demo.cpp:194
```
`assertion_info.statement()`:
```
Expand Down
1 change: 1 addition & 0 deletions include/libassert/assert.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1165,6 +1165,7 @@ namespace libassert {

std::string header(int width = 0, const color_scheme& scheme = get_color_scheme()) const;
std::string tagline(const color_scheme& scheme = get_color_scheme()) const;
std::string location() const;
std::string statement(const color_scheme& scheme = get_color_scheme()) const;
std::string print_binary_diagnostics(int width = 0, const color_scheme& scheme = get_color_scheme()) const;
std::string print_extra_diagnostics(int width = 0, const color_scheme& scheme = get_color_scheme()) const;
Expand Down
4 changes: 4 additions & 0 deletions src/assert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,10 @@ namespace libassert {
}
}

std::string assertion_info::location() const {
return stringf("%s:%d", get_path_handler()->resolve_path(file_name).data(), line);
}

std::string assertion_info::statement(const color_scheme& scheme) const {
return stringf(
" %s\n",
Expand Down

0 comments on commit 4ca0370

Please sign in to comment.