[LVI] Add trunc to i1 handling. (#124480)
[llvm-project.git] / libc / test / include / iscanonical_test.c
blob670b48b0008e3e85ec4669ca5da4c09bd2b6a1c7
1 //===-- Unittests for iscanonical macro -----------------------------------===//
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 //===----------------------------------------------------------------------===//
8 int iscanonical(double);
9 int iscanonicalf(float);
10 int iscanonicall(long double);
12 #include "include/llvm-libc-macros/math-function-macros.h"
14 #include <assert.h>
16 // check if macro is defined
17 #ifndef iscanonical
18 #error "iscanonical macro is not defined"
19 #else
20 int main(void) {
21 assert(iscanonical(__builtin_nans("")) == 0);
22 assert(iscanonical(__builtin_nansf("")) == 0);
23 assert(iscanonical(__builtin_nansl("")) == 0);
24 assert(iscanonical(1.819f) == 1);
25 assert(iscanonical(-1.726) == 1);
26 assert(iscanonical(1.426L) == 1);
27 return 0;
29 #endif