Ignore:
Timestamp:
Jan 14, 2013, 9:19:06 AM (7 years ago)
Author:
sam
Message:

color: write the RGB to HSL routine and its associated unit tests.

File:
1 edited

Legend:

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

    r2217 r2218  
    102102        }
    103103    }
     104
     105    LOLUNIT_TEST(RGBToHSL)
     106    {
     107        for (int r = 0; r < 20; r++)
     108        for (int g = 0; g < 20; g++)
     109        for (int b = 0; b < 20; b++)
     110        {
     111            vec3 v1 = vec3(r / 20.f, g / 20.f, b / 20.f);
     112            vec3 v2 = Color::RGBToHSL(v1);
     113            vec3 v3 = Color::HSVToHSL(Color::RGBToHSV(v1));
     114
     115            LOLUNIT_ASSERT_DOUBLES_EQUAL(v2.x, v3.x, 0.0001);
     116            LOLUNIT_ASSERT_DOUBLES_EQUAL(v2.y, v3.y, 0.0001);
     117            LOLUNIT_ASSERT_DOUBLES_EQUAL(v2.z, v3.z, 0.0001);
     118        }
     119    }
    104120};
    105121
Note: See TracChangeset for help on using the changeset viewer.