Changeset 2217 for trunk/test


Ignore:
Timestamp:
Jan 13, 2013, 11:44:30 PM (7 years ago)
Author:
sam
Message:

color: optimise RGB to HSV conversion routine using my latest findings,
and add a simple unit test function.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/color.cpp

    r2207 r2217  
    8787        }
    8888    }
     89
     90    LOLUNIT_TEST(RGBToHSV)
     91    {
     92        for (int r = 0; r < 20; r++)
     93        for (int g = 0; g < 20; g++)
     94        for (int b = 0; b < 20; b++)
     95        {
     96            vec3 v1 = vec3(r / 20.f, g / 20.f, b / 20.f);
     97            vec3 v2 = Color::HSVToRGB(Color::RGBToHSV(v1));
     98
     99            LOLUNIT_ASSERT_DOUBLES_EQUAL(v1.r, v2.r, 0.0001);
     100            LOLUNIT_ASSERT_DOUBLES_EQUAL(v1.g, v2.g, 0.0001);
     101            LOLUNIT_ASSERT_DOUBLES_EQUAL(v1.b, v2.b, 0.0001);
     102        }
     103    }
    89104};
    90105
Note: See TracChangeset for help on using the changeset viewer.