blob: ab4d400b9ccc9ce0b7bcfabddc4d512d1b4d8bc1 [file] [log] [blame]
Leon Scroggins III1252ec42017-01-11 12:59:43 -05001/*
2 * Copyright 2017 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#include "Test.h"
9
10#include "SkColor.h"
11
12DEF_TEST(ColorToHSVRoundTrip, reporter) {
13 SkScalar hsv[3];
14 for (U8CPU r = 0; r <= 255; r++) {
15 for (U8CPU g = 0; g <= 255; g++) {
16 for (U8CPU b = 0; b <= 255; b++) {
Cary Clark6cdb7d32018-04-24 14:47:16 -040017 SkColor color = SkColorSetRGB(r, g, b);
Leon Scroggins III1252ec42017-01-11 12:59:43 -050018 SkColorToHSV(color, hsv);
19 SkColor result = SkHSVToColor(0xFF, hsv);
20 if (result != color) {
21 ERRORF(reporter, "HSV roundtrip mismatch!\n"
22 "\toriginal: %X\n"
23 "\tHSV: %f, %f, %f\n"
24 "\tresult: %X\n",
25 color, hsv[0], hsv[1], hsv[2], result);
26 }
27 }
28 }
29 }
30}