Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1739)

Unified Diff: core/fxcodec/codec/fx_codec_jpx_unittest.cpp

Issue 2466203002: Fix founding difference in pdfium_test on AdobeCMYK_to_sRGB (Closed)
Patch Set: Remove blank line Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « core/fxcodec/codec/fx_codec_icc.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/fxcodec/codec/fx_codec_jpx_unittest.cpp
diff --git a/core/fxcodec/codec/fx_codec_jpx_unittest.cpp b/core/fxcodec/codec/fx_codec_jpx_unittest.cpp
index 820a618f5b83d7b5bfdca0a0cf1869f5e8051a3d..3ef14e62c357db97687d9974ea14f1bf4fb90915 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;
« no previous file with comments | « core/fxcodec/codec/fx_codec_icc.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698