mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-13 19:44:28 +00:00
test: add strokeTrim tests
This commit is contained in:
parent
566b327f09
commit
669b5badf4
2 changed files with 30 additions and 0 deletions
|
@ -246,7 +246,26 @@ TEST_CASE("Stroke join", "[capiStrokeJoin]")
|
|||
REQUIRE(tvg_shape_get_stroke_miterlimit(paint, &ml) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(ml == 1000.0f);
|
||||
|
||||
REQUIRE(tvg_paint_del(paint) == TVG_RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
TEST_CASE("Stroke trim", "[capiStrokeTrim]")
|
||||
{
|
||||
Tvg_Paint* paint = tvg_shape_new();
|
||||
REQUIRE(paint);
|
||||
|
||||
float begin, end;
|
||||
bool simultaneous;
|
||||
|
||||
REQUIRE(tvg_shape_get_stroke_trim(NULL, &begin, &end, &simultaneous) == TVG_RESULT_INVALID_ARGUMENT);
|
||||
REQUIRE(tvg_shape_get_stroke_trim(paint, &begin, &end, &simultaneous) == TVG_RESULT_SUCCESS);
|
||||
|
||||
REQUIRE(tvg_shape_set_stroke_trim(NULL, 0.33, 0.66, false) == TVG_RESULT_INVALID_ARGUMENT);
|
||||
REQUIRE(tvg_shape_set_stroke_trim(paint, 0.33, 0.66, false) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(tvg_shape_get_stroke_trim(paint, &begin, &end, &simultaneous) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(begin == Approx(0.33).margin(0.000001));
|
||||
REQUIRE(end == Approx(0.66).margin(0.000001));
|
||||
REQUIRE(simultaneous == false);
|
||||
|
||||
REQUIRE(tvg_paint_del(paint) == TVG_RESULT_SUCCESS);
|
||||
}
|
||||
|
|
|
@ -203,6 +203,17 @@ TEST_CASE("Stroking", "[tvgShape]")
|
|||
REQUIRE(shape->strokeMiterlimit() == 1000.0f);
|
||||
REQUIRE(shape->strokeMiterlimit(-0.001f) == Result::NonSupport);
|
||||
|
||||
//Stroke Trim
|
||||
float begin, end;
|
||||
REQUIRE(shape->strokeTrim(&begin, &end) == true);
|
||||
REQUIRE(begin == Approx(0.0).margin(0.000001));
|
||||
REQUIRE(end == Approx(1.0).margin(0.000001));
|
||||
|
||||
REQUIRE(shape->strokeTrim(0.3, 0.88, false) == Result::Success);
|
||||
REQUIRE(shape->strokeTrim(&begin, &end) == false);
|
||||
REQUIRE(begin == Approx(0.3).margin(0.000001));
|
||||
REQUIRE(end == Approx(0.88).margin(0.000001));
|
||||
|
||||
//Stroke Order After Stroke Setting
|
||||
REQUIRE(shape->order(true) == Result::Success);
|
||||
REQUIRE(shape->order(false) == Result::Success);
|
||||
|
|
Loading…
Add table
Reference in a new issue