summaryrefslogtreecommitdiff
path: root/core/fxcodec/codec/fx_codec_jpx_unittest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'core/fxcodec/codec/fx_codec_jpx_unittest.cpp')
-rw-r--r--core/fxcodec/codec/fx_codec_jpx_unittest.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/core/fxcodec/codec/fx_codec_jpx_unittest.cpp b/core/fxcodec/codec/fx_codec_jpx_unittest.cpp
index 820a618f5b..3ef14e62c3 100644
--- a/core/fxcodec/codec/fx_codec_jpx_unittest.cpp
+++ b/core/fxcodec/codec/fx_codec_jpx_unittest.cpp
@@ -19,6 +19,29 @@ static unsigned char stream_data[] = {
0x84, 0x85, 0x86, 0x87, // Include some hi-bytes, too.
};
+union Float_t {
+ Float_t(float num = 0.0f) : f(num) {}
+
+ int32_t i;
+ FX_FLOAT f;
+};
+
+TEST(fxcodec, CMYK_Rounding) {
+ // Testing all floats from 0.0 to 1.0 takes about 35 seconds in release
+ // builds and much longer in debug builds, so just test the known-dangerous
+ // range.
+ const FX_FLOAT startValue = 0.001f;
+ const FX_FLOAT endValue = 0.003f;
+ FX_FLOAT R = 0.0f, G = 0.0f, B = 0.0f;
+ // Iterate through floats by incrementing the representation, as discussed in
+ // https://randomascii.wordpress.com/2012/01/23/stupid-float-tricks-2/
+ for (Float_t f = startValue; f.f < endValue; f.i++) {
+ AdobeCMYK_to_sRGB(f.f, f.f, f.f, f.f, R, G, B);
+ }
+ // Check various other 'special' numbers.
+ AdobeCMYK_to_sRGB(0.0f, 0.25f, 0.5f, 1.0f, R, G, B);
+}
+
TEST(fxcodec, DecodeDataNullDecodeData) {
unsigned char buffer[16];
DecodeData* ptr = nullptr;