mirror of
https://github.com/siemens-mobile-hacks/llvm-c166.git
synced 2026-11-25 21:45:57 +00:00
This removes the dependency on the host C library (hermetic tests), makes sure the tests actually do something in release builds (where assert() is a noop), and makes better and more consistent failure messages. This is just a thin wrapper over the existing framework which repackages the C++ interface into something consumable by C code. I tried to keep the interface consistent, but of course, many of the framework features are C++ only. Registering more than one test function was tricky, so the framework currently supports only one. The main trick here was getting the static library linker to extract LibcCTest.cpp.o from libLibcTest.unit.a. Since C test cases don't instantiate static CTest objects in their own translation unit like C++ tests do (they cannot do that portably), nothing in the object file referenced LibcCTest.cpp. I made this work by introducing libc_c_test_anchor() and calling it explicitly inside the generated libc_c_test_run() function.
23 lines
866 B
C
23 lines
866 B
C
//===-- Unittests for fpclassify macro ------------------------------------===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
#include "include/llvm-libc-macros/math-function-macros.h"
|
|
#include "test/UnitTest/LibcCTest.h"
|
|
|
|
// check if macro is defined
|
|
#ifndef fpclassify
|
|
#error "fpclassify macro is not defined"
|
|
#else
|
|
TEST(fpclassify) {
|
|
EXPECT_TRUE(fpclassify(1.819f) == FP_NORMAL);
|
|
EXPECT_TRUE(fpclassify(-1.726) == FP_NORMAL);
|
|
EXPECT_TRUE(fpclassify(1.426L) == FP_NORMAL);
|
|
EXPECT_TRUE(fpclassify(-0.0f) == FP_ZERO);
|
|
EXPECT_TRUE(fpclassify(0.0) == FP_ZERO);
|
|
EXPECT_TRUE(fpclassify(-0.0L) == FP_ZERO);
|
|
}
|
|
#endif
|