Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / courgette / image_utils_unittest.cc
bloba90c19be063490b98a869bccc2eed07f12017ba9
1 // Copyright 2015 The Chromium 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.
5 #include "courgette/image_utils.h"
7 #include "testing/gtest/include/gtest/gtest.h"
9 namespace courgette {
11 namespace {
13 TEST(ImageUtilsTest, Read) {
14 uint8 test_data[] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF, 00};
15 EXPECT_EQ(0x2301U, Read16LittleEndian(test_data));
16 EXPECT_EQ(0x67452301U, Read32LittleEndian(test_data));
17 EXPECT_EQ(0xEFCDAB8967452301ULL, Read64LittleEndian(test_data));
19 // These will break big-endian architectures, which we don't yet support.
20 EXPECT_EQ(0x2301U, ReadU16(test_data, 0));
21 EXPECT_EQ(0x4523U, ReadU16(test_data, 1));
22 EXPECT_EQ(0x67452301U, ReadU32(test_data, 0));
23 EXPECT_EQ(0x89674523U, ReadU32(test_data, 1));
24 EXPECT_EQ(0xEFCDAB8967452301ULL, ReadU64(test_data, 0));
25 EXPECT_EQ(0x00EFCDAB89674523ULL, ReadU64(test_data, 1));
28 } // namespace
30 } // namespace courgette