| // Copyright 2024 The Pigweed Authors |
| // |
| // Licensed under the Apache License, Version 2.0 (the "License"); you may not |
| // use this file except in compliance with the License. You may obtain a copy of |
| // the License at |
| // |
| // https://www.apache.org/licenses/LICENSE-2.0 |
| // |
| // Unless required by applicable law or agreed to in writing, software |
| // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| // License for the specific language governing permissions and limitations under |
| // the License. |
| |
| #include "pw_color/color.h" |
| |
| #include "gtest/gtest.h" |
| #include "pw_color/colors_pico8.h" |
| |
| namespace pw::color { |
| namespace { |
| |
| TEST(ColorsPico8Rgb565, Exists) { |
| EXPECT_EQ(kColorsPico8Rgb565[kColorDarkBlue], 0x194a); |
| } |
| |
| TEST(ColorToRGB565, FromRGB) { |
| EXPECT_EQ(ColorRgba(0x1d, 0x2b, 0x53).ToRgb565(), |
| kColorsPico8Rgb565[kColorDarkBlue]); |
| } |
| |
| TEST(ColorToRGB565, FromRGBA) { |
| EXPECT_EQ(ColorRgba(kColorsPico8Rgba8888[kColorDarkBlue]).ToRgb565(), |
| kColorsPico8Rgb565[kColorDarkBlue]); |
| } |
| |
| TEST(ConvertColor, FromRGBA888) { |
| ColorRgba color(kColorsPico8Rgba8888[kColorIndigo]); |
| EXPECT_EQ(color.a, 0xff); |
| EXPECT_EQ(color.r, 0x83); |
| EXPECT_EQ(color.g, 0x76); |
| EXPECT_EQ(color.b, 0x9c); |
| } |
| |
| TEST(ConvertColor, FromRGB565) { |
| ColorRgba color(kColorsPico8Rgb565[kColorIndigo]); |
| EXPECT_EQ(color.a, 0xff); |
| EXPECT_EQ(color.r, 0x83); |
| EXPECT_EQ(color.g, 0x75); |
| EXPECT_EQ(color.b, 0x9c); |
| } |
| |
| } // namespace |
| } // namespace pw::color |