Skip to content

Commit

Permalink
more basic color comparison tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Novakasa committed Mar 1, 2022
1 parent 4ec8fcc commit 4c51690
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/pbio/src/color/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,4 @@ int32_t pbio_get_cone_cost(const pbio_color_hsv_t *a, const pbio_color_hsv_t *b)
fix16_sq(dely)),
fix16_sq(delz));
return fix16_to_int(cdist);
}
}
25 changes: 22 additions & 3 deletions lib/pbio/test/src/color.c
Original file line number Diff line number Diff line change
Expand Up @@ -350,14 +350,33 @@ static void test_color_hsv_compression(void *env) {

static void test_color_hsv_cost(void *env) {
pbio_color_hsv_t color_a;
// pbio_color_hsv_t color_b;
pbio_color_hsv_t color_b;

// red
// color compared to itself should give 0
color_a.h = 0;
color_a.s = 100;
color_a.v = 100;

tt_want_int_op(pbio_get_cone_cost(&color_a, &color_a), ==, 0);

// blacks with different saturations/hues should be the same
color_a.h = 230;
color_a.s = 23;
color_a.v = 0;

color_b.h = 23;
color_b.s = 99;
color_b.v = 0;
tt_want_int_op(pbio_get_cone_cost(&color_a, &color_b), ==, 0);

// max value with different saturations/hues should be different
color_a.h = 230;
color_a.s = 23;
color_a.v = 100;

color_b.h = 23;
color_b.s = 99;
color_b.v = 100;
tt_want_int_op(pbio_get_cone_cost(&color_a, &color_b), >, 0);
}

struct testcase_t pbio_color_tests[] = {
Expand Down

0 comments on commit 4c51690

Please sign in to comment.