Fix bug in Hsv::saturationInt().

This commit is contained in:
David Capello 2010-12-11 22:09:37 -03:00
parent dbebaec92b
commit 7e8ea5886a
2 changed files with 12 additions and 1 deletions

View File

@ -77,7 +77,7 @@ int Hsv::hueInt() const
int Hsv::saturationInt() const
{
return int(floor(m_hue*100.0 + 0.5));
return int(floor(m_saturation*100.0 + 0.5));
}
int Hsv::valueInt() const

View File

@ -23,6 +23,17 @@ ostream& operator<<(ostream& os, const Hsv& hsv)
<< hsv.value() << ")";
}
TEST(Hsv, Ctor)
{
EXPECT_EQ(35.0, Hsv(35.0, 0.50, 0.75).hue());
EXPECT_EQ(0.50, Hsv(35.0, 0.50, 0.75).saturation());
EXPECT_EQ(0.75, Hsv(35.0, 0.50, 0.75).value());
EXPECT_EQ(35, Hsv(35.0, 0.50, 0.75).hueInt());
EXPECT_EQ(50, Hsv(35.0, 0.50, 0.75).saturationInt());
EXPECT_EQ(75, Hsv(35.0, 0.50, 0.75).valueInt());
EXPECT_EQ(Hsv(0, 0, 0), Hsv());
}
TEST(Hsv, FromRgb)
{
EXPECT_EQ(Hsv( 0.0, 0.000, 0.000), Hsv(Rgb( 0, 0, 0)));