Donner
C++20 SVG rendering library
Loading...
Searching...
No Matches
donner::svg::AsciiImage Struct Reference

Stores an ASCII representation of a rendered image, and supports diffing it to another image. More...

#include "donner/svg/renderer/tests/RendererTestUtils.h"

Collaboration diagram for donner::svg::AsciiImage:
[legend]

Public Member Functions

bool matches (std::string_view golden) const
 Compare the rendered ASCII image to a golden ASCII string, and output the image differences if any.
 

Public Attributes

std::string generated
 ASCII art of generated image, with lines separated by \n
 

Detailed Description

Stores an ASCII representation of a rendered image, and supports diffing it to another image.

Member Function Documentation

◆ matches()

bool donner::svg::AsciiImage::matches ( std::string_view golden) const
inline

Compare the rendered ASCII image to a golden ASCII string, and output the image differences if any.

Example:

<rect width="8" height="8" fill="white" />
)");
EXPECT_TRUE(generatedAscii.matches(R"(
@@@@@@@@........
@@@@@@@@........
@@@@@@@@........
@@@@@@@@........
@@@@@@@@........
@@@@@@@@........
@@@@@@@@........
@@@@@@@@........
................
................
................
................
................
................
................
................
)"));
static AsciiImage renderToAsciiImage(std::string_view svgFragment, Vector2i size=kTestSvgDefaultSize)
Render the given SVG fragment into ASCII art.
Definition RendererTestUtils.h:153
Stores an ASCII representation of a rendered image, and supports diffing it to another image.
Definition RendererTestUtils.h:31
bool matches(std::string_view golden) const
Compare the rendered ASCII image to a golden ASCII string, and output the image differences if any.
Definition RendererTestUtils.h:68
Parameters
goldenThe golden ASCII image to compare the rendered output to, which should be a multiline string, whitespaces and the first newlines are removed.
Returns
true if the image matches.

The documentation for this struct was generated from the following file: