|
|
Donner SVG Editor & Engine
SVG-native editor and embeddable SVG2 + CSS3 engine in C++20, with GPU (WebGPU) and compact CPU renderers, built for correctness, security, and performance.
|
This guide is for developers writing or reviewing Donner tests. A failing test must explain the mismatch from the log alone. Prefer one assertion that matches the whole value over several assertions that expose only the first broken field.
The default pattern is:
Use EXPECT_EQ for scalar values where the expected and actual output is already complete and clear. Do not use EXPECT_EQ to validate arrays, byte buffers, record sequences, or a cluster of related fields.
Validate vectors, spans, fixed arrays, and other ordered collections with ElementsAre, ElementsAreArray, Pointwise, UnorderedElementsAre, or SizeIs plus a separate targeted condition only when the contents are not part of the contract.
Prefer:
Avoid:
The matcher form reports whether the failure is cardinality, ordering, or a specific element mismatch.
For structs, match the named fields that define the contract with Field and AllOf.
Then use the record matcher inside sequence matchers:
For nested records, compose matchers instead of flattening the assertion site:
Use small domain helpers when the test reads in domain terms. Box helpers are a good example:
This keeps the test contract visible:
When a helper is useful in more than one test file, promote it to an existing test utility such as donner/base/tests/BaseTestUtils.h or a local package test utility. Keep highly specific helpers in the test file.
Use MATCHER, MATCHER_P, or MATCHER_Pn when Field composition is not expressive enough or when a mismatch needs a custom explanation.
Use ExplainMatchResult inside custom matchers so nested matcher diagnostics survive. Write to result_listener when the matcher performs custom logic that would otherwise fail as a bare boolean.
If a failure prints raw bytes, enum integers, or an opaque type name, add a PrintTo overload in the same namespace as the type for that test binary.
For enums, prefer an operator<< in production when the type is part of the debugging surface. Use test-local PrintTo only when the printer is only useful for test diagnostics.
Pixel and byte assertions are array assertions. Match the whole pixel or buffer.
Prefer:
Avoid:
For large buffers, custom matchers should report the first mismatching index and the decoded domain coordinate when available, such as pixel (x, y) and channel.
Before adding or approving a test assertion, check: