[flang] Accept polymorphic component element in storage_size
[llvm-project.git] / libc / test / src / network / ntohl_test.cpp
blobbc52a97c87672039a1ffde0380f16628a80a8d5f
1 //===-- Unittests for ntohl -----------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #include "src/__support/endian.h"
10 #include "src/network/htonl.h"
11 #include "src/network/ntohl.h"
12 #include "test/UnitTest/Test.h"
14 TEST(LlvmLibcNtohl, SmokeTest) {
15 uint32_t original = 0x67452301;
16 uint32_t swapped = 0x01234567;
17 #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
18 EXPECT_EQ(__llvm_libc::ntohl(original), swapped);
19 #endif
20 #if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
21 EXPECT_EQ(__llvm_libc::ntohl(original), original);
22 #endif
25 TEST(LlvmLibcNtohl, CompleteTest) {
26 uint32_t original = 0x01234567;
27 EXPECT_EQ(__llvm_libc::ntohl(__llvm_libc::htonl(original)), original);