MCPcopy Create free account
hub / github.com/FastLED/FastLED / FL_TEST_FILE

Function FL_TEST_FILE

tests/fl/gfx/xypath.cpp:17–330  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15#include "fl/gfx/xypath_impls.h"
16
17FL_TEST_FILE(FL_FILEPATH) {
18
19
20#define MESSAGE_TILE(TILE) \
21 FL_MESSAGE("\nTile:\n" \
22 << " " << TILE.at(0, 0) << " " << TILE.at(1, 0) << "\n" \
23 << " " << TILE.at(0, 1) << " " << TILE.at(1, 1) << "\n");
24
25#define MESSAGE_TILE_ROW(TILE, ROW) \
26 FL_MESSAGE("\nTile Row " << ROW << ":\n" \
27 << " " << TILE.at(0, ROW) << " " << TILE.at(1, ROW) << "\n");
28
29
30FL_TEST_CASE("LinePath") {
31 fl::LinePath path(0.0f, 0.0f, 1.0f, 1.0f);
32 fl::vec2<float> xy = path.compute(0.5f);
33 FL_REQUIRE(xy.x == 0.5f);
34 FL_REQUIRE(xy.y == 0.5f);
35
36 xy = path.compute(1.0f);
37 FL_REQUIRE(xy.x == 1.0f);
38 FL_REQUIRE(xy.y == 1.0f);
39
40 xy = path.compute(0.0f);
41 FL_REQUIRE(xy.x == 0.0f);
42 FL_REQUIRE(xy.y == 0.0f);
43}
44
45FL_TEST_CASE("LinePath at_subpixel") {
46 // Tests that we can get the correct subpixel values at center point 0,0
47 auto line = fl::make_shared<fl::LinePath>(-1.0f, -1.0f, 1.0f, -1.0f);
48 fl::XYPath path(line);
49 path.setDrawBounds(2,2);
50 fl::Tile2x2_u8 tile = path.at_subpixel(0);
51 FL_REQUIRE_EQ(fl::vec2<uint16_t>(0, 0), tile.origin());
52 MESSAGE_TILE(tile);
53 FL_REQUIRE_EQ(255, tile.at(0, 0));
54}
55
56FL_TEST_CASE("LinePath simple float sweep") {
57 // Tests that we can get the correct gaussian values at center point 0,0
58 auto point = fl::make_shared<fl::LinePath>(0, 1.f, 1.f, 1.f);
59 fl::XYPath path(point);
60 auto xy = path.at(0);
61 //MESSAGE_TILE(tile);
62 FL_REQUIRE_EQ(xy, fl::vec2<float>(0.0f, 1.f));
63 xy = path.at(1);
64 FL_REQUIRE_EQ(xy, fl::vec2<float>(1.f, 1.f));
65}
66
67FL_TEST_CASE("Point at exactly the middle") {
68 // Tests that we can get the correct gaussian values at center point 0,0
69 auto point = fl::make_shared<fl::PointPath>(0.0, 0.0); // Right in middle.
70 fl::XYPath path(point);
71 path.setDrawBounds(2,2);
72 // auto xy = path.at(0);
73 fl::Tile2x2_u8 sp = path.at_subpixel(0);
74 //MESSAGE_TILE(tile);

Callers

nothing calls this directly

Calls 9

maxFunction · 0.85
almost_equalFunction · 0.85
originMethod · 0.80
computeMethod · 0.45
setDrawBoundsMethod · 0.45
at_subpixelMethod · 0.45
atMethod · 0.45
push_backMethod · 0.45
set_scaleMethod · 0.45

Tested by

no test coverage detected