brintos

brintos / llvm-project-archived public Read only

0
0
Text · 826 B · 3f0ea0f Raw
26 lines · cpp
1//===-- Unittests for inet_addr -------------------------------------------===//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-exception6//7//===----------------------------------------------------------------------===//8 9#include "src/arpa/inet/htonl.h"10#include "src/arpa/inet/inet_addr.h"11#include "test/UnitTest/Test.h"12 13namespace LIBC_NAMESPACE_DECL {14 15TEST(LlvmLibcInetAddr, ValidTest) {16  ASSERT_EQ(htonl(0x7f010204), inet_addr("127.1.2.4"));17  ASSERT_EQ(htonl(0x7f010004), inet_addr("127.1.4"));18}19 20TEST(LlvmLibcInetAddr, InvalidTest) {21  ASSERT_EQ(htonl(0xffffffff), inet_addr(""));22  ASSERT_EQ(htonl(0xffffffff), inet_addr("x"));23}24 25} // namespace LIBC_NAMESPACE_DECL26