OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "core/fxge/skia/fx_skia_device.cpp" |
| 6 #include "testing/fx_string_testhelpers.h" |
| 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 |
| 9 namespace { |
| 10 |
| 11 uint32_t _GetBits32(const uint8_t* pData, int bitpos, int nbits) { |
| 12 int result = 0; |
| 13 for (int i = 0; i < nbits; i++) |
| 14 if (pData[(bitpos + i) / 8] & (1 << (7 - (bitpos + i) % 8))) { |
| 15 result |= 1 << (nbits - i - 1); |
| 16 } |
| 17 return result; |
| 18 } |
| 19 |
| 20 } // namespace |
| 21 |
| 22 TEST(fxge, GetBits32) { |
| 23 unsigned char data[] = {0xDE, 0x3F, 0xB1, 0x7C, 0x12, 0x9A, 0x04, 0x56}; |
| 24 for (int nbits = 1; nbits <= 32; ++nbits) { |
| 25 for (int bitpos = 0; bitpos < (int)sizeof(data) * 8 - nbits; ++bitpos) { |
| 26 uint32_t ref = _GetBits32(data, bitpos, nbits); |
| 27 uint32_t test = GetBits32(data, bitpos, nbits); |
| 28 EXPECT_TRUE(ref == test); |
| 29 } |
| 30 } |
| 31 } |
OLD | NEW |