Refactor color conversion functions for consistent naming and improved readability
This commit is contained in:
@@ -10,8 +10,8 @@ namespace test {
|
||||
namespace gfx {
|
||||
|
||||
using ::testing::ElementsAreArray;
|
||||
using yaze::app::gfx::ConvertRGBtoSNES;
|
||||
using yaze::app::gfx::ConvertSNEStoRGB;
|
||||
using yaze::app::gfx::ConvertRgbToSnes;
|
||||
using yaze::app::gfx::ConvertSnestoRGB;
|
||||
using yaze::app::gfx::Extract;
|
||||
using yaze::app::gfx::SnesPalette;
|
||||
|
||||
@@ -25,45 +25,45 @@ unsigned int test_convert(snes_color col) {
|
||||
}
|
||||
} // namespace
|
||||
|
||||
TEST(SNESPaletteTest, AddColor) {
|
||||
TEST(SnesPaletteTest, AddColor) {
|
||||
yaze::app::gfx::SnesPalette palette;
|
||||
yaze::app::gfx::SnesColor color;
|
||||
palette.AddColor(color);
|
||||
ASSERT_EQ(palette.size(), 1);
|
||||
}
|
||||
|
||||
TEST(SNESColorTest, ConvertRGBtoSNES) {
|
||||
TEST(SnesColorTest, ConvertRgbToSnes) {
|
||||
snes_color color = {132, 132, 132};
|
||||
uint16_t snes = ConvertRGBtoSNES(color);
|
||||
uint16_t snes = ConvertRgbToSnes(color);
|
||||
ASSERT_EQ(snes, 0x4210);
|
||||
}
|
||||
|
||||
TEST(SNESColorTest, ConvertSNEStoRGB) {
|
||||
TEST(SnesColorTest, ConvertSnestoRGB) {
|
||||
uint16_t snes = 0x4210;
|
||||
snes_color color = ConvertSNEStoRGB(snes);
|
||||
snes_color color = ConvertSnestoRGB(snes);
|
||||
ASSERT_EQ(color.red, 132);
|
||||
ASSERT_EQ(color.green, 132);
|
||||
ASSERT_EQ(color.blue, 132);
|
||||
}
|
||||
|
||||
TEST(SNESColorTest, ConvertSNESToRGB_Binary) {
|
||||
TEST(SnesColorTest, ConvertSnesToRGB_Binary) {
|
||||
uint16_t red = 0b0000000000011111;
|
||||
uint16_t blue = 0b0111110000000000;
|
||||
uint16_t green = 0b0000001111100000;
|
||||
uint16_t purple = 0b0111110000011111;
|
||||
snes_color testcolor;
|
||||
|
||||
testcolor = ConvertSNEStoRGB(red);
|
||||
testcolor = ConvertSnestoRGB(red);
|
||||
ASSERT_EQ(0xFF0000, test_convert(testcolor));
|
||||
testcolor = ConvertSNEStoRGB(green);
|
||||
testcolor = ConvertSnestoRGB(green);
|
||||
ASSERT_EQ(0x00FF00, test_convert(testcolor));
|
||||
testcolor = ConvertSNEStoRGB(blue);
|
||||
testcolor = ConvertSnestoRGB(blue);
|
||||
ASSERT_EQ(0x0000FF, test_convert(testcolor));
|
||||
testcolor = ConvertSNEStoRGB(purple);
|
||||
testcolor = ConvertSnestoRGB(purple);
|
||||
ASSERT_EQ(0xFF00FF, test_convert(testcolor));
|
||||
}
|
||||
|
||||
TEST(SNESColorTest, Extraction) {
|
||||
TEST(SnesColorTest, Extraction) {
|
||||
// red, blue, green, purple
|
||||
char data[8] = {0x1F, 0x00, 0x00, 0x7C, static_cast<char>(0xE0),
|
||||
0x03, 0x1F, 0x7C};
|
||||
@@ -75,7 +75,7 @@ TEST(SNESColorTest, Extraction) {
|
||||
ASSERT_EQ(0xFF00FF, test_convert(pal[3]));
|
||||
}
|
||||
|
||||
TEST(SNESColorTest, Convert) {
|
||||
TEST(SnesColorTest, Convert) {
|
||||
// red, blue, green, purple white
|
||||
char data[10] = {0x1F,
|
||||
0x00,
|
||||
|
||||
Reference in New Issue
Block a user