apache / apache/arrow-nanoarrow
Automatically append ArrowError messages to failed test assertions
- Dominant language
- C
- Stars
- 249
- Forks
- 68
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 11
Description
Many functions in nanoarrow accept an `ArrowError*` which receives a message describing the error; frequently more informative than the `ArrowErrorCode`. Although there are tests asserting error message content, most other tests ignore the error message entirely. This can make debugging those other tests frustrating and leads to ad-hoc assertions like
```c++
EXPECT_EQ(ArrowIpcDecoderVerifyHeader(&decoder, data, &error),
NANOARROW_OK)
<< error.message;
```
There are a couple of GTest tricks we could use to be more ergonomic, like defining a new assertion macro:
```c++
TEST(Foo, Bar) {
// ...
// Just check that the error code is NANOARROW_OK:
EXPECT_OK(ArrowSchemaViewInit(&schema_view, &schema, nullptr));
// ... or also if the code is anything else, append error->message to the assertion
EXPECT_OK(ArrowSchemaViewInit(&schema_view, &schema, &error), &error);
}
```
It'd even be possible to elide the extra macro argument by introducing a C++ wrapper for ArrowError:
```c++
TEST(Foo, Bar) {
// ...
nanoarrow::UniqueError error;
EXPECT_OK(ArrowSchemaViewInit(&schema_view, &schema, &error)); // no repetitive argument
EXPECT_OK(ArrowSchemaViewInit(&schema_view, &schema, nullptr)); // still fine
}
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.