brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.3 KiB · 6f900aa Raw
39 lines · cpp
1//===-- Unittests for complex ---------------------------------------------===//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 "include/llvm-libc-macros/complex-macros.h"10#include "test/UnitTest/FPMatcher.h"11#include "test/UnitTest/Test.h"12 13TEST(LlvmLibcComplexTest, VersionMacro) {14  EXPECT_EQ(__STDC_VERSION_COMPLEX_H__, 202311L);15}16 17TEST(LlvmLibcComplexTest, IMacro) { EXPECT_CFP_EQ(1.0fi, I); }18 19TEST(LlvmLibcComplexTest, _Complex_IMacro) { EXPECT_CFP_EQ(1.0fi, _Complex_I); }20 21TEST(LlvmLibcComplexTest, CMPLXMacro) {22  EXPECT_CFP_EQ(CMPLX(0, 1.0), I);23  EXPECT_CFP_EQ(CMPLX(1.0, 0), 1.0);24  EXPECT_CFP_EQ(CMPLXF(0, 1.0f), I);25  EXPECT_CFP_EQ(CMPLXF(1.0f, 0), 1.0f);26  EXPECT_CFP_EQ(CMPLXL(0, 1.0l), I);27  EXPECT_CFP_EQ(CMPLXL(1.0l, 0), 1.0l);28 29#ifdef LIBC_TYPES_HAS_CFLOAT1630  EXPECT_CFP_EQ(CMPLXF16(0, 1.0), I);31  EXPECT_CFP_EQ(CMPLXF16(1.0, 0), 1.0);32#endif // LIBC_TYPES_HAS_CFLOAT1633 34#ifdef LIBC_TYPES_HAS_CFLOAT12835  EXPECT_CFP_EQ(CMPLXF128(0, 1.0), I);36  EXPECT_CFP_EQ(CMPLXF128(1.0, 0), 1.0);37#endif // LIBC_TYPES_HAS_CFLOAT12838}39