/*
- * Copyright 2012 Facebook, Inc.
+ * Copyright 2011-present Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* limitations under the License.
*/
-#include "folly/Bits.h"
+#include <folly/lang/Bits.h>
-#include <gtest/gtest.h>
+#include <folly/portability/GTest.h>
using namespace folly;
TEST(Endian, Basic) {
uint8_t v8 = 0x12;
- uint8_t v8s = v8;
+ uint8_t v8s = 0x12;
uint16_t v16 = 0x1234;
- uint16_t v16s = bswap_16(v16);
+ uint16_t v16s = 0x3412;
uint32_t v32 = 0x12345678;
- uint32_t v32s = bswap_32(v32);
+ uint32_t v32s = 0x78563412;
uint64_t v64 = 0x123456789abcdef0ULL;
- uint64_t v64s = bswap_64(v64);
+ uint64_t v64s = 0xf0debc9a78563412ULL;
-#if __BYTE_ORDER == __LITTLE_ENDIAN
+#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
#define GEN1(sz) \
EXPECT_EQ(v##sz, Endian::little(v##sz)); \
EXPECT_EQ(v##sz##s, Endian::big(v##sz)); \
EXPECT_EQ(v##sz##s, Endian::big##sz(v##sz));
-#elif __BYTE_ORDER == __BIG_ENDIAN
+#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
#define GEN1(sz) \
EXPECT_EQ(v##sz##s, Endian::little(v##sz)); \
#else
# error Your machine uses a weird endianness!
-#endif /* __BYTE_ORDER */
+#endif /* __BYTE_ORDER__ */
#define GEN(sz) \
EXPECT_EQ(v##sz##s, Endian::swap(v##sz)); \