*/
#include <thorvg_capi.h>
-#include "catch.hpp"
+#include "../catch.hpp"
TEST_CASE("Basic Create", "[capiRadialGradient]")
{
- Tvg_Gradient *gradient = NULL;
- gradient = tvg_radial_gradient_new();
- REQUIRE(gradient != NULL);
+ Tvg_Gradient *gradient = tvg_radial_gradient_new();
+ REQUIRE(gradient);
REQUIRE(tvg_gradient_del(gradient) == TVG_RESULT_SUCCESS);
}
TEST_CASE("Set gradient center point and radius", "[capiRadialGradient]")
{
- Tvg_Gradient *gradient = NULL;
- float cx = 0.0, cy = 0.0, radius = 0.0;
-
- gradient = tvg_radial_gradient_new();
-
- REQUIRE(gradient != NULL);
+ Tvg_Gradient *gradient = tvg_radial_gradient_new();
+ REQUIRE(gradient);
REQUIRE(tvg_radial_gradient_set(gradient, 10.0, 15.0, 30.0) == TVG_RESULT_SUCCESS);
+ float cx, cy, radius;
REQUIRE(tvg_radial_gradient_get(gradient, &cx, &cy, &radius) == TVG_RESULT_SUCCESS);
REQUIRE(cx == 10.0);
REQUIRE(cy == 15.0);
TEST_CASE("Set gradient in shape", "[capiRadialGradient]")
{
- Tvg_Paint *shape = NULL;
- Tvg_Gradient *gradient = NULL;
+ REQUIRE(tvg_shape_set_radial_gradient(NULL, NULL) == TVG_RESULT_INVALID_ARGUMENT);
+
+ Tvg_Paint *shape = tvg_shape_new();
+ REQUIRE(shape);
- REQUIRE(tvg_shape_set_radial_gradient(shape, gradient) == TVG_RESULT_INVALID_ARGUMENT);
-
- gradient = tvg_radial_gradient_new();
- REQUIRE(gradient != NULL);
- REQUIRE(tvg_shape_set_radial_gradient(shape, gradient) == TVG_RESULT_INVALID_ARGUMENT);
+ Tvg_Gradient *gradient = tvg_radial_gradient_new();
+ REQUIRE(gradient);
- shape = tvg_shape_new();
- REQUIRE(shape != NULL);
+ REQUIRE(tvg_shape_set_radial_gradient(NULL, gradient) == TVG_RESULT_INVALID_ARGUMENT);
REQUIRE(tvg_gradient_del(gradient) == TVG_RESULT_SUCCESS);
- gradient = NULL;
- REQUIRE(tvg_shape_set_radial_gradient(shape, gradient) == TVG_RESULT_MEMORY_CORRUPTION);
+ REQUIRE(tvg_shape_set_radial_gradient(shape, NULL) == TVG_RESULT_MEMORY_CORRUPTION);
REQUIRE(tvg_paint_del(shape) == TVG_RESULT_SUCCESS);
}
TEST_CASE("Set/Get color stops", "[capiRadialGradient]")
{
- Tvg_Paint *shape = NULL;
- Tvg_Gradient *gradient = NULL;
+ Tvg_Paint *shape = tvg_shape_new();
+ REQUIRE(shape);
- Tvg_Color_Stop color_stops[2] =
- {
+ Tvg_Gradient *gradient = tvg_radial_gradient_new();
+ REQUIRE(gradient);
+
+ Tvg_Color_Stop color_stops[2] = {
{.offset=0.0, .r=0, .g=0, .b=0, .a=255},
{.offset=1, .r=0, .g=255, .b=0, .a=255},
};
- const Tvg_Color_Stop *color_stops_ret = NULL;
- uint32_t color_stops_count_ret = 0;
-
- shape = tvg_shape_new();
- REQUIRE(shape != NULL);
-
- gradient = tvg_radial_gradient_new();
- REQUIRE(gradient != NULL);
+ const Tvg_Color_Stop *color_stops_ret;
+ uint32_t color_stops_count_ret;
REQUIRE(tvg_gradient_set_color_stops(gradient, color_stops, 2) == TVG_RESULT_SUCCESS);
-
REQUIRE(tvg_gradient_get_color_stops(gradient, &color_stops_ret, &color_stops_count_ret) == TVG_RESULT_SUCCESS);
REQUIRE(color_stops_count_ret == 2);
TEST_CASE("Clear gradient data", "[capiRadialGradient]")
{
- Tvg_Paint *shape = NULL;
- Tvg_Gradient *gradient = NULL;
+ Tvg_Paint *shape = tvg_shape_new();
+ REQUIRE(shape);
+
+ Tvg_Gradient *gradient = tvg_radial_gradient_new();
+ REQUIRE(gradient);
- Tvg_Color_Stop color_stops[2] =
- {
+ Tvg_Color_Stop color_stops[2] = {
{.offset=0.0, .r=0, .g=0, .b=0, .a=255},
{.offset=1, .r=0, .g=255, .b=0, .a=255},
};
- const Tvg_Color_Stop *color_stops_ret = NULL;
- uint32_t color_stops_count_ret = 0;
-
- shape = tvg_shape_new();
- REQUIRE(shape != NULL);
-
- gradient = tvg_radial_gradient_new();
- REQUIRE(gradient != NULL);
+ const Tvg_Color_Stop *color_stops_ret;
+ uint32_t color_stops_count_ret;
REQUIRE(tvg_gradient_set_color_stops(gradient, color_stops, 2) == TVG_RESULT_SUCCESS);
-
- REQUIRE(tvg_gradient_get_color_stops(gradient, &color_stops_ret,
- &color_stops_count_ret) == TVG_RESULT_SUCCESS);
-
- REQUIRE(color_stops_ret != NULL);
+ REQUIRE(tvg_gradient_get_color_stops(gradient, &color_stops_ret, &color_stops_count_ret) == TVG_RESULT_SUCCESS);
+ REQUIRE(color_stops_ret);
REQUIRE(color_stops_count_ret == 2);
REQUIRE(tvg_gradient_set_color_stops(gradient, NULL, 0) == TVG_RESULT_SUCCESS);
- REQUIRE(tvg_gradient_get_color_stops(gradient, &color_stops_ret,
- &color_stops_count_ret) == TVG_RESULT_SUCCESS);
-
+ REQUIRE(tvg_gradient_get_color_stops(gradient, &color_stops_ret, &color_stops_count_ret) == TVG_RESULT_SUCCESS);
REQUIRE(color_stops_ret == NULL);
REQUIRE(color_stops_count_ret == 0);
TEST_CASE("Set/Get gradient spread", "[capiRadialGradient]")
{
- Tvg_Gradient *gradient = NULL;
- Tvg_Stroke_Fill spread = TVG_STROKE_FILL_REPEAT;
-
- gradient = tvg_radial_gradient_new();
- REQUIRE(gradient != NULL);
+ Tvg_Gradient *gradient = tvg_radial_gradient_new();
+ REQUIRE(gradient);
REQUIRE(tvg_gradient_set_spread(gradient, TVG_STROKE_FILL_PAD) == TVG_RESULT_SUCCESS);
- REQUIRE(tvg_gradient_get_spread(gradient, &spread) == TVG_RESULT_SUCCESS);
+ Tvg_Stroke_Fill spread;
+ REQUIRE(tvg_gradient_get_spread(gradient, &spread) == TVG_RESULT_SUCCESS);
REQUIRE(spread == TVG_STROKE_FILL_PAD);
- REQUIRE(tvg_gradient_del(gradient) == TVG_RESULT_SUCCESS);
- gradient = NULL;
- REQUIRE(tvg_gradient_del(gradient) == TVG_RESULT_INVALID_ARGUMENT);
+ REQUIRE(tvg_gradient_del(gradient) == TVG_RESULT_SUCCESS);
+ REQUIRE(tvg_gradient_del(NULL) == TVG_RESULT_INVALID_ARGUMENT);
}
\ No newline at end of file