apple / apple/foundationdb

Support more types with `ASSERT_*` macros

Open
#6,662 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
16.7k
Forks
1.6k
Avg merge
1d 20h
Merged PRs (30d)
126

Description

The `ASSERT_*` macros help to create more readable output on assertion failures. However, they work by converting both operands to `long`. This results in lost precision and confusing printed messages, such as:

```
Assertion failed @ :
expression:
tpsRate.get() >= 0
expands to:
0 >= 0
```

The following 3 improvements could help our use of these macros:
- Avoid losing precision when printing assertion failure details
- Support better floating point arithmetic in assertions (e.g. [googletest assertion macros](https://github.com/google/googletest/blob/main/docs/reference/assertions.md#floating-point-comparison-floating-point))
- Support `ASSERT_EQ` and `ASSERT_NE` for string comparisons.

Contributor guide

Open the contributing guide

Research direction

Start by locating the ASSERT_* macro definitions and their existing assertion tests; inspect how operands are converted before failure details are printed. Compare the requested precision, floating-point, and string-comparison behaviors with the current implementation, then define tests covering each supported case as the completion criteria.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
testing
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.