From 366a7cdfe485f256bec265e1a2ba8d818f187f1c Mon Sep 17 00:00:00 2001 From: Pavel Krajcevski Date: Wed, 19 Feb 2014 19:35:29 -0500 Subject: [PATCH] Add some YCoCg tests --- Base/test/TestPixel.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/Base/test/TestPixel.cpp b/Base/test/TestPixel.cpp index 9d95fd9..fc97dca 100644 --- a/Base/test/TestPixel.cpp +++ b/Base/test/TestPixel.cpp @@ -278,3 +278,33 @@ TEST(Pixel, ScaleColor) { EXPECT_EQ(bd[i], newBitDepth[i]); } } + +TEST(YCoCgPixel, Conversion) { + + FasTC::Pixel p; + p.R() = 127; + p.G() = 127; + p.B() = 127; + p.A() = 255; + + FasTC::YCoCgPixel yp (p); + EXPECT_EQ(yp.Y(), 127); + EXPECT_EQ(yp.Co(), 128); + EXPECT_EQ(yp.Cg(), 128); +} + +TEST(YCoCgPixel, ConvertBack) { + FasTC::Pixel p; + + p.R() = 241; + p.G() = 22; + p.B() = 102; + p.A() = 124; + + FasTC::YCoCgPixel yp (p); + FasTC::Pixel bp = yp.ToRGBA(); + + for(int i = 0; i < 4; i++) { + EXPECT_NEAR(p[i], bp[i], 1); + } +}