[flang] Accept polymorphic component element in storage_size
[llvm-project.git] / libc / test / src / network / htons_test.cpp
blobf9bd77bad25d872e7bb745a06fb1f9a8df6d5180
1 //===-- Unittests for htons -----------------------------------------------===//
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/htons.h"
11 #include "src/network/ntohs.h"
12 #include "test/UnitTest/Test.h"
14 TEST(LlvmLibcHtons, SmokeTest) {
15 uint16_t original = 0x2301;
16 uint16_t swapped = 0x0123;
17 #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
18 EXPECT_EQ(__llvm_libc::htons(original), swapped);
19 #endif
20 #if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
21 EXPECT_EQ(__llvm_libc::htons(original), original);
22 #endif
25 TEST(LlvmLibcHtons, CompleteTest) {
26 uint16_t original = 0x0123;
27 EXPECT_EQ(__llvm_libc::htons(__llvm_libc::ntohs(original)), original);