1/* 2 * Copyright 2012 The WebRTC Project Authors. All rights reserved. 3 * 4 * Use of this source code is governed by a BSD-style license 5 * that can be found in the LICENSE file in the root of the source 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 11#include "webrtc/base/basictypes.h" 12 13#include "webrtc/base/gunit.h" 14 15namespace rtc { 16 17TEST(BasicTypesTest, Endian) { 18 uint16_t v16 = 0x1234u; 19 uint8_t first_byte = *reinterpret_cast<uint8_t*>(&v16); 20#if defined(RTC_ARCH_CPU_LITTLE_ENDIAN) 21 EXPECT_EQ(0x34u, first_byte); 22#elif defined(RTC_ARCH_CPU_BIG_ENDIAN) 23 EXPECT_EQ(0x12u, first_byte); 24#endif 25} 26 27TEST(BasicTypesTest, SizeOfConstants) { 28 EXPECT_EQ(8u, sizeof(INT64_C(0))); 29 EXPECT_EQ(8u, sizeof(UINT64_C(0))); 30 EXPECT_EQ(8u, sizeof(INT64_C(0x1234567887654321))); 31 EXPECT_EQ(8u, sizeof(UINT64_C(0x8765432112345678))); 32} 33 34// Test CPU_ macros 35#if !defined(CPU_ARM) && defined(__arm__) 36#error expected CPU_ARM to be defined. 37#endif 38#if !defined(CPU_X86) && (defined(WEBRTC_WIN) || defined(WEBRTC_MAC) && !defined(WEBRTC_IOS)) 39#error expected CPU_X86 to be defined. 40#endif 41#if !defined(RTC_ARCH_CPU_LITTLE_ENDIAN) && \ 42 (defined(WEBRTC_WIN) || defined(WEBRTC_MAC) && !defined(WEBRTC_IOS) || defined(CPU_X86)) 43#error expected RTC_ARCH_CPU_LITTLE_ENDIAN to be defined. 44#endif 45 46// TODO(fbarchard): Test all macros in basictypes.h 47 48} // namespace rtc 49