| 15 | #include "fl/gfx/xypath_impls.h" |
| 16 | |
| 17 | FL_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 | |
| 30 | FL_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 | |
| 45 | FL_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 | |
| 56 | FL_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 | |
| 67 | FL_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); |
nothing calls this directly
no test coverage detected