1 // Copyright 2015 The Chromium Authors
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"
9 #include "testing/gtest/include/gtest/gtest.h"
15 TEST(ImageUtilsTest, Read) {
16 uint8_t test_data[] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF, 00};
17 EXPECT_EQ(0x2301U, Read16LittleEndian(test_data));
18 EXPECT_EQ(0x67452301U, Read32LittleEndian(test_data));
19 EXPECT_EQ(0xEFCDAB8967452301ULL, Read64LittleEndian(test_data));
21 // These will break big-endian architectures, which we don't yet support.
22 EXPECT_EQ(0x2301U, ReadU16(test_data, 0));
23 EXPECT_EQ(0x4523U, ReadU16(test_data, 1));
24 EXPECT_EQ(0x67452301U, ReadU32(test_data, 0));
25 EXPECT_EQ(0x89674523U, ReadU32(test_data, 1));
26 EXPECT_EQ(0xEFCDAB8967452301ULL, ReadU64(test_data, 0));
27 EXPECT_EQ(0x00EFCDAB89674523ULL, ReadU64(test_data, 1));
32 } // namespace courgette