diff options
author | Elliott Hughes <enh@google.com> | 2017-08-29 15:28:33 -0700 |
---|---|---|
committer | Elliott Hughes <enh@google.com> | 2017-08-29 15:32:18 -0700 |
commit | 45da3263249f55cd7a0d927128a285ac20720367 (patch) | |
tree | 8224951e0b8b70b032a3f5b577c62d37e0bf2e64 /tests/float_test.cpp | |
parent | 0d5d0746e8b88dab66038d6150cb92b62467aac1 (diff) |
Add tests for all C11 headers.
Well, all except <threads.h> which we have no current plans to implement.
The only thing this turned up is that clang's <float.h> doesn't define
FLT_HAS_SUBNORM/DBL_HAS_SUBNORM/LDBL_HAS_SUBNORM, so for now we assert
that those are missing so that when we get a fixed clang, we notice.
Also the <tgmath.h> is utterly perfunctory, but seems like an appropriate
amount of effort to put in.
Bug: N/A
Test: ran tests
Change-Id: I7f7a7040b3271ceda625bee8a40a9d8cef52ee44
Diffstat (limited to 'tests/float_test.cpp')
-rw-r--r-- | tests/float_test.cpp | 127 |
1 files changed, 127 insertions, 0 deletions
diff --git a/tests/float_test.cpp b/tests/float_test.cpp new file mode 100644 index 000000000..a75214e20 --- /dev/null +++ b/tests/float_test.cpp @@ -0,0 +1,127 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <gtest/gtest.h> + +#include <float.h> + +TEST(float_h, macros) { +#if !defined(FLT_RADIX) +#error FLT_RADIX +#endif +#if !defined(DECIMAL_DIG) +#error DECIMAL_DIG +#endif +#if !defined(FLT_DECIMAL_DIG) +#error FLT_DECIMAL_DIG +#endif +#if !defined(DBL_DECIMAL_DIG) +#error DBL_DECIMAL_DIG +#endif +#if !defined(LDBL_DECIMAL_DIG) +#error LDBL_DECIMAL_DIG +#endif +#if !defined(FLT_MIN) +#error FLT_MIN +#endif +#if !defined(DBL_MIN) +#error DBL_MIN +#endif +#if !defined(LDBL_MIN) +#error LDBL_MIN +#endif +#if !defined(FLT_EPSILON) +#error FLT_EPSILON +#endif +#if !defined(DBL_EPSILON) +#error DBL_EPSILON +#endif +#if !defined(LDBL_EPSILON) +#error LDBL_EPSILON +#endif +#if !defined(FLT_DIG) +#error FLT_DIG +#endif +#if !defined(DBL_DIG) +#error DBL_DIG +#endif +#if !defined(LDBL_DIG) +#error LDBL_DIG +#endif +#if !defined(FLT_MANT_DIG) +#error FLT_MANT_DIG +#endif +#if !defined(DBL_MANT_DIG) +#error DBL_MANT_DIG +#endif +#if !defined(LDBL_MANT_DIG) +#error LDBL_MANT_DIG +#endif +#if !defined(FLT_MIN_EXP) +#error FLT_MIN_EXP +#endif +#if !defined(DBL_MIN_EXP) +#error DBL_MIN_EXP +#endif +#if !defined(LDBL_MIN_EXP) +#error LDBL_MIN_EXP +#endif +#if !defined(FLT_MIN_10_EXP) +#error FLT_MIN_10_EXP +#endif +#if !defined(DBL_MIN_10_EXP) +#error DBL_MIN_10_EXP +#endif +#if !defined(LDBL_MIN_10_EXP) +#error LDBL_MIN_10_EXP +#endif +#if !defined(FLT_MAX_EXP) +#error FLT_MAX_EXP +#endif +#if !defined(DBL_MAX_EXP) +#error DBL_MAX_EXP +#endif +#if !defined(LDBL_MAX_EXP) +#error LDBL_MAX_EXP +#endif +#if !defined(FLT_MAX_10_EXP) +#error FLT_MAX_10_EXP +#endif +#if !defined(DBL_MAX_10_EXP) +#error DBL_MAX_10_EXP +#endif +#if !defined(LDBL_MAX_10_EXP) +#error LDBL_MAX_10_EXP +#endif +#if !defined(FLT_ROUNDS) +#error FLT_ROUNDS +#endif +#if !defined(FLT_EVAL_METHOD) +#error FLT_EVAL_METHOD +#endif +// TODO: FLT_HAS_SUBNORM currently missing from clang. Negate this test when fixed. +#if defined(FLT_HAS_SUBNORM) +#error FLT_HAS_SUBNORM +#endif +// TODO: DBL_HAS_SUBNORM currently missing from clang. Negate this test when fixed. +#if defined(DBL_HAS_SUBNORM) +#error DBL_HAS_SUBNORM +#endif +// TODO: LDBL_HAS_SUBNORM currently missing from clang. Negate this test when fixed. +#if defined(LDBL_HAS_SUBNORM) +#error LDBL_HAS_SUBNORM +#endif +} |