mirror of
https://github.com/aseprite/aseprite.git
synced 2025-01-14 12:40:55 +00:00
Move src/tests/test_color.cpp to src/app/color_unittest.cpp.
This commit is contained in:
parent
d8489d4a6b
commit
d6ac296390
52
src/app/color_unittest.cpp
Normal file
52
src/app/color_unittest.cpp
Normal file
@ -0,0 +1,52 @@
|
||||
/* ASE - Allegro Sprite Editor
|
||||
* Copyright (C) 2001-2010 David Capello
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "tests/test.h"
|
||||
#include "app/color.h"
|
||||
|
||||
inline std::ostream& operator<<(std::ostream& os, const Color& color) {
|
||||
return os << color.toString();
|
||||
}
|
||||
|
||||
TEST(Color, fromRgb)
|
||||
{
|
||||
EXPECT_EQ(32, Color::fromRgb(32, 16, 255).getRed());
|
||||
EXPECT_EQ(16, Color::fromRgb(32, 16, 255).getGreen());
|
||||
EXPECT_EQ(255, Color::fromRgb(32, 16, 255).getBlue());
|
||||
}
|
||||
|
||||
TEST(Color, fromHsv)
|
||||
{
|
||||
EXPECT_EQ(32, Color::fromHsv(32, 16, 255).getHue());
|
||||
EXPECT_EQ(16, Color::fromHsv(32, 16, 255).getSaturation());
|
||||
EXPECT_EQ(255, Color::fromHsv(32, 16, 255).getValue());
|
||||
}
|
||||
|
||||
TEST(Color, fromString)
|
||||
{
|
||||
EXPECT_EQ(Color::fromRgb(0, 0, 0), Color::fromString("rgb{0,0,0}"));
|
||||
EXPECT_EQ(Color::fromRgb(32, 16, 255), Color::fromString("rgb{32,16,255}"));
|
||||
EXPECT_EQ(Color::fromHsv(32, 64, 99), Color::fromString("hsv{32,64,99}"));
|
||||
}
|
||||
|
||||
TEST(Color, toString)
|
||||
{
|
||||
EXPECT_EQ("rgb{0,0,0}", Color::fromRgb(0, 0, 0).toString());
|
||||
EXPECT_EQ("rgb{32,16,255}", Color::fromRgb(32, 16, 255).toString());
|
||||
EXPECT_EQ("hsv{32,64,99}", Color::fromHsv(32, 64, 99).toString());
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
/* ASE - Allegro Sprite Editor
|
||||
* Copyright (C) 2001-2010 David Capello
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "tests/test.h"
|
||||
|
||||
#include "app/color.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
test_init();
|
||||
|
||||
ASSERT(Color::fromRgb(32, 16, 255).getRed() == 32);
|
||||
ASSERT(Color::fromRgb(32, 16, 255).getGreen() == 16);
|
||||
ASSERT(Color::fromRgb(32, 16, 255).getBlue() == 255);
|
||||
|
||||
ASSERT(Color::fromString("rgb{0,0,0}") == Color::fromRgb(0, 0, 0));
|
||||
ASSERT(Color::fromString("rgb{32,16,255}") == Color::fromRgb(32, 16, 255));
|
||||
ASSERT(Color::fromString("hsv{32,64,99}") == Color::fromHsv(32, 64, 99));
|
||||
ASSERT("rgb{0,0,0}" == Color::fromRgb(0, 0, 0).toString());
|
||||
ASSERT("rgb{32,16,255}" == Color::fromRgb(32, 16, 255).toString());
|
||||
ASSERT("hsv{32,64,99}" == Color::fromHsv(32, 64, 99).toString());
|
||||
|
||||
return test_exit();
|
||||
}
|
||||
|
||||
END_OF_MAIN();
|
Loading…
Reference in New Issue
Block a user