Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
byteorder_unittest.cpp
Go to the documentation of this file.
1// Copyright 2019 The PDFium Authors
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/fxcrt/byteorder.h"
6
7#include "core/fxcrt/fx_system.h"
8#include "testing/gmock/include/gmock/gmock.h"
9#include "testing/gtest/include/gtest/gtest.h"
10
11namespace {
12
13constexpr uint32_t kTestValues32[] = {
14 0x0, 0x1, 0x2, 0x3, 0x4, 0xfe,
15 0xff, 0x100, 0x101, 0xffff, 0x10000, 0x123456,
16 0x345167, 0x2f3e4a5b, 0xff000000, 0xfffffffe, 0xffffffff};
17
18} // namespace
19
20namespace fxcrt {
21
23 // Since there are so few values, test them all.
24 for (uint32_t v = 0; v < 0x10000; ++v) {
25 const uint16_t v16 = v;
28 }
29}
30
37
39 // Since there are so few values, test them all.
40 for (uint32_t v = 0; v < 0x10000; ++v) {
41 const uint16_t v16 = v;
44 }
45}
46
53
55 const uint8_t kBuf[2] = {0xff, 0xfe};
57}
58
60 const uint8_t kBuf[2] = {0xff, 0xfe};
62}
63
65 const uint8_t kBuf[4] = {0xff, 0xfe, 0xfd, 0xfc};
66 EXPECT_EQ(0xfcfdfeff, GetUInt32LSBFirst(kBuf));
67}
68
70 const uint8_t kBuf[4] = {0xff, 0xfe, 0xfd, 0xfc};
71 EXPECT_EQ(0xfffefdfc, GetUInt32MSBFirst(kBuf));
72}
73
79
85
87 uint8_t buf[4];
88 PutUInt32LSBFirst(0xfffefdfc, buf);
89 EXPECT_THAT(buf, testing::ElementsAre(0xfc, 0xfd, 0xfe, 0xff));
90}
91
93 uint8_t buf[4];
94 PutUInt32MSBFirst(0xfffefdfc, buf);
95 EXPECT_THAT(buf, testing::ElementsAre(0xff, 0xfe, 0xfd, 0xfc));
96}
97
98} // namespace fxcrt
TEST(ByteOrder, FromLE16)