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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « core/fxcodec/codec/fx_codec_icc.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stdint.h> 5 #include <stdint.h>
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "core/fxcodec/codec/codec_int.h" 9 #include "core/fxcodec/codec/codec_int.h"
10 #include "testing/fx_string_testhelpers.h" 10 #include "testing/fx_string_testhelpers.h"
11 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
12 12
13 static const OPJ_OFF_T kSkipError = static_cast<OPJ_OFF_T>(-1); 13 static const OPJ_OFF_T kSkipError = static_cast<OPJ_OFF_T>(-1);
14 static const OPJ_SIZE_T kReadError = static_cast<OPJ_SIZE_T>(-1); 14 static const OPJ_SIZE_T kReadError = static_cast<OPJ_SIZE_T>(-1);
15 static const OPJ_SIZE_T kWriteError = static_cast<OPJ_SIZE_T>(-1); 15 static const OPJ_SIZE_T kWriteError = static_cast<OPJ_SIZE_T>(-1);
16 16
17 static unsigned char stream_data[] = { 17 static unsigned char stream_data[] = {
18 0x00, 0x01, 0x02, 0x03, 18 0x00, 0x01, 0x02, 0x03,
19 0x84, 0x85, 0x86, 0x87, // Include some hi-bytes, too. 19 0x84, 0x85, 0x86, 0x87, // Include some hi-bytes, too.
20 }; 20 };
21 21
22 union Float_t {
23 Float_t(float num = 0.0f) : f(num) {}
24
25 int32_t i;
26 FX_FLOAT f;
27 };
28
29 TEST(fxcodec, CMYK_Rounding) {
30 // Testing all floats from 0.0 to 1.0 takes about 35 seconds in release
31 // builds and much longer in debug builds, so just test the known-dangerous
32 // range.
33 const FX_FLOAT startValue = 0.001f;
34 const FX_FLOAT endValue = 0.003f;
35 FX_FLOAT R = 0.0f, G = 0.0f, B = 0.0f;
36 // Iterate through floats by incrementing the representation, as discussed in
37 // https://randomascii.wordpress.com/2012/01/23/stupid-float-tricks-2/
38 for (Float_t f = startValue; f.f < endValue; f.i++) {
39 AdobeCMYK_to_sRGB(f.f, f.f, f.f, f.f, R, G, B);
40 }
41 // Check various other 'special' numbers.
42 AdobeCMYK_to_sRGB(0.0f, 0.25f, 0.5f, 1.0f, R, G, B);
43 }
44
22 TEST(fxcodec, DecodeDataNullDecodeData) { 45 TEST(fxcodec, DecodeDataNullDecodeData) {
23 unsigned char buffer[16]; 46 unsigned char buffer[16];
24 DecodeData* ptr = nullptr; 47 DecodeData* ptr = nullptr;
25 48
26 // Error codes, not segvs, should callers pass us a nullptr pointer. 49 // Error codes, not segvs, should callers pass us a nullptr pointer.
27 EXPECT_EQ(kReadError, opj_read_from_memory(buffer, sizeof(buffer), ptr)); 50 EXPECT_EQ(kReadError, opj_read_from_memory(buffer, sizeof(buffer), ptr));
28 EXPECT_EQ(kWriteError, opj_write_from_memory(buffer, sizeof(buffer), ptr)); 51 EXPECT_EQ(kWriteError, opj_write_from_memory(buffer, sizeof(buffer), ptr));
29 EXPECT_EQ(kSkipError, opj_skip_from_memory(1, ptr)); 52 EXPECT_EQ(kSkipError, opj_skip_from_memory(1, ptr));
30 EXPECT_FALSE(opj_seek_from_memory(1, ptr)); 53 EXPECT_FALSE(opj_seek_from_memory(1, ptr));
31 } 54 }
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 EXPECT_NE(img.comps[0].h, img.comps[1].h); 546 EXPECT_NE(img.comps[0].h, img.comps[1].h);
524 EXPECT_NE(img.comps[0].w, img.comps[2].w); 547 EXPECT_NE(img.comps[0].w, img.comps[2].w);
525 EXPECT_NE(img.comps[0].h, img.comps[2].h); 548 EXPECT_NE(img.comps[0].h, img.comps[2].h);
526 } 549 }
527 FX_Free(img.comps[0].data); 550 FX_Free(img.comps[0].data);
528 FX_Free(img.comps[1].data); 551 FX_Free(img.comps[1].data);
529 FX_Free(img.comps[2].data); 552 FX_Free(img.comps[2].data);
530 } 553 }
531 FX_Free(img.comps); 554 FX_Free(img.comps);
532 } 555 }
OLDNEW
« 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