private static void TestLChToLxy(float l, float c, float h, float expectedX, float expectedY)
        {
            float lxy_l, lxy_x, lxy_y;

            LChUtils.LChToLxy(l, c, h, out lxy_l, out lxy_x, out lxy_y);

            Assert.That(lxy_l, Is.EqualTo(l).Within(Epsilon));
            Assert.That(lxy_x, Is.EqualTo(expectedX).Within(Epsilon));
            Assert.That(lxy_y, Is.EqualTo(expectedY).Within(Epsilon));
        }
        private static void TestLxyToLCh(float l, float x, float y, float expectedC, float expectedH)
        {
            float lch_l, lch_c, lch_h;

            LChUtils.LxyToLCh(l, x, y, out lch_l, out lch_c, out lch_h);

            Assert.That(lch_l, Is.EqualTo(l).Within(Epsilon));
            Assert.That(lch_c, Is.EqualTo(expectedC).Within(Epsilon));
            Assert.That(lch_h, Is.EqualTo(expectedH).Within(Epsilon));
        }
        private static void TestLChToCieXYZ(LxyModel model, float l, float c, float h, float expectedX, float expectedY, float expectedZ)
        {
            float x, y, z;

            LChUtils.LChToCieXYZ(l, c, h, out x, out y, out z, model);

            Assert.That(x, Is.EqualTo(expectedX).Within(Epsilon));
            Assert.That(y, Is.EqualTo(expectedY).Within(Epsilon));
            Assert.That(z, Is.EqualTo(expectedZ).Within(Epsilon));
        }
        private static void TestCieXYZToLCh(LxyModel model, float x, float y, float z, float expectedL, float expectedC, float expectedH)
        {
            float l, c, h;

            LChUtils.CieXYZToLCh(x, y, z, out l, out c, out h, model);

            Assert.That(l, Is.EqualTo(expectedL).Within(Epsilon));
            Assert.That(c, Is.EqualTo(expectedC).Within(Epsilon));
            Assert.That(h, Is.EqualTo(expectedH).Within(Epsilon));
        }
        public void LChToLxy_is_inverse_LxyToLCh()
        {
            for (float l = 0; l <= 1; l += Step)
            {
                for (float x = -1; x <= 1; x += Step)
                {
                    for (float y = -1; y <= 1; y += Step)
                    {
                        float lch_l, lch_c, lch_h;
                        LChUtils.LxyToLCh(l, x, y, out lch_l, out lch_c, out lch_h);

                        TestLChToLxy(lch_l, lch_c, lch_h, x, y);
                    }
                }
            }
        }
        public void LChToCieXYZ_is_inverse_LChToCieXYZ()
        {
            for (int m = 0; m < 2; m++)
            {
                for (float x = Step; x <= 1; x += Step)
                {
                    for (float y = Step; y <= 1; y += Step)
                    {
                        for (float z = Step; z <= 1; z += Step)
                        {
                            var model = m == 0 ? LxyModel.Lab : LxyModel.Luv;

                            float l, c, h;
                            LChUtils.CieXYZToLCh(x, y, z, out l, out c, out h, model);

                            TestLChToCieXYZ(model, l, c, h, x, y, z);
                        }
                    }
                }
            }
        }