#include "src/__support/FPUtil/FPBits.h"
#include "src/__support/FPUtil/PlatformDefs.h"
+#include "test/UnitTest/RoundingModeUtils.h"
#include "test/UnitTest/Test.h"
-#include "utils/testutils/RoundingModeUtils.h"
// #include <stdio.h>
// namespace __llvm_libc {
#ifndef LIBC_COPT_PRINTF_DISABLE_FLOAT
TEST_F(LlvmLibcSPrintfTest, FloatHexExpConv) {
- __llvm_libc::testutils::ForceRoundingMode r(
- __llvm_libc::testutils::RoundingMode::Nearest);
+ __llvm_libc::fputil::testing::ForceRoundingMode r(
+ __llvm_libc::fputil::testing::RoundingMode::Nearest);
double inf = __llvm_libc::fputil::FPBits<double>::inf().get_val();
double nan = __llvm_libc::fputil::FPBits<double>::build_nan(1);
// Rounding Mode Tests.
{
- __llvm_libc::testutils::ForceRoundingMode r(
- __llvm_libc::testutils::RoundingMode::Nearest);
+ __llvm_libc::fputil::testing::ForceRoundingMode r(
+ __llvm_libc::fputil::testing::RoundingMode::Nearest);
written = __llvm_libc::sprintf(buff, "%.1a", 0x1.08p0);
ASSERT_STREQ_LEN(written, buff, "0x1.0p+0");
}
{
- __llvm_libc::testutils::ForceRoundingMode r(
- __llvm_libc::testutils::RoundingMode::Upward);
+ __llvm_libc::fputil::testing::ForceRoundingMode r(
+ __llvm_libc::fputil::testing::RoundingMode::Upward);
written = __llvm_libc::sprintf(buff, "%.1a", 0x1.08p0);
ASSERT_STREQ_LEN(written, buff, "0x1.1p+0");
}
{
- __llvm_libc::testutils::ForceRoundingMode r(
- __llvm_libc::testutils::RoundingMode::Downward);
+ __llvm_libc::fputil::testing::ForceRoundingMode r(
+ __llvm_libc::fputil::testing::RoundingMode::Downward);
written = __llvm_libc::sprintf(buff, "%.1a", 0x1.08p0);
ASSERT_STREQ_LEN(written, buff, "0x1.0p+0");
}
{
- __llvm_libc::testutils::ForceRoundingMode r(
- __llvm_libc::testutils::RoundingMode::TowardZero);
+ __llvm_libc::fputil::testing::ForceRoundingMode r(
+ __llvm_libc::fputil::testing::RoundingMode::TowardZero);
written = __llvm_libc::sprintf(buff, "%.1a", 0x1.08p0);
ASSERT_STREQ_LEN(written, buff, "0x1.0p+0");
}
TEST_F(LlvmLibcSPrintfTest, FloatDecimalConv) {
- __llvm_libc::testutils::ForceRoundingMode r(
- __llvm_libc::testutils::RoundingMode::Nearest);
+ __llvm_libc::fputil::testing::ForceRoundingMode r(
+ __llvm_libc::fputil::testing::RoundingMode::Nearest);
double inf = __llvm_libc::fputil::FPBits<double>::inf().get_val();
double nan = __llvm_libc::fputil::FPBits<double>::build_nan(1);
// Rounding Mode Tests.
{
- __llvm_libc::testutils::ForceRoundingMode r(
- __llvm_libc::testutils::RoundingMode::Nearest);
+ __llvm_libc::fputil::testing::ForceRoundingMode r(
+ __llvm_libc::fputil::testing::RoundingMode::Nearest);
written = __llvm_libc::sprintf(buff, "%.1f", 1.75);
ASSERT_STREQ_LEN(written, buff, "1.8");
}
{
- __llvm_libc::testutils::ForceRoundingMode r(
- __llvm_libc::testutils::RoundingMode::Upward);
+ __llvm_libc::fputil::testing::ForceRoundingMode r(
+ __llvm_libc::fputil::testing::RoundingMode::Upward);
written = __llvm_libc::sprintf(buff, "%.1f", 1.75);
ASSERT_STREQ_LEN(written, buff, "1.8");
}
{
- __llvm_libc::testutils::ForceRoundingMode r(
- __llvm_libc::testutils::RoundingMode::Downward);
+ __llvm_libc::fputil::testing::ForceRoundingMode r(
+ __llvm_libc::fputil::testing::RoundingMode::Downward);
written = __llvm_libc::sprintf(buff, "%.1f", 1.75);
ASSERT_STREQ_LEN(written, buff, "1.7");
}
{
- __llvm_libc::testutils::ForceRoundingMode r(
- __llvm_libc::testutils::RoundingMode::TowardZero);
+ __llvm_libc::fputil::testing::ForceRoundingMode r(
+ __llvm_libc::fputil::testing::RoundingMode::TowardZero);
written = __llvm_libc::sprintf(buff, "%.1f", 1.75);
ASSERT_STREQ_LEN(written, buff, "1.7");
}
TEST_F(LlvmLibcSPrintfTest, FloatExponentConv) {
- __llvm_libc::testutils::ForceRoundingMode r(
- __llvm_libc::testutils::RoundingMode::Nearest);
+ __llvm_libc::fputil::testing::ForceRoundingMode r(
+ __llvm_libc::fputil::testing::RoundingMode::Nearest);
double inf = __llvm_libc::fputil::FPBits<double>::inf().get_val();
double nan = __llvm_libc::fputil::FPBits<double>::build_nan(1);
// Rounding Mode Tests.
{
- __llvm_libc::testutils::ForceRoundingMode r(
- __llvm_libc::testutils::RoundingMode::Nearest);
+ __llvm_libc::fputil::testing::ForceRoundingMode r(
+ __llvm_libc::fputil::testing::RoundingMode::Nearest);
written = __llvm_libc::sprintf(buff, "%.1e", 1.75);
ASSERT_STREQ_LEN(written, buff, "1.8e+00");
}
{
- __llvm_libc::testutils::ForceRoundingMode r(
- __llvm_libc::testutils::RoundingMode::Upward);
+ __llvm_libc::fputil::testing::ForceRoundingMode r(
+ __llvm_libc::fputil::testing::RoundingMode::Upward);
written = __llvm_libc::sprintf(buff, "%.1e", 1.75);
ASSERT_STREQ_LEN(written, buff, "1.8e+00");
}
{
- __llvm_libc::testutils::ForceRoundingMode r(
- __llvm_libc::testutils::RoundingMode::Downward);
+ __llvm_libc::fputil::testing::ForceRoundingMode r(
+ __llvm_libc::fputil::testing::RoundingMode::Downward);
written = __llvm_libc::sprintf(buff, "%.1e", 1.75);
ASSERT_STREQ_LEN(written, buff, "1.7e+00");
}
{
- __llvm_libc::testutils::ForceRoundingMode r(
- __llvm_libc::testutils::RoundingMode::TowardZero);
+ __llvm_libc::fputil::testing::ForceRoundingMode r(
+ __llvm_libc::fputil::testing::RoundingMode::TowardZero);
written = __llvm_libc::sprintf(buff, "%.1e", 1.75);
ASSERT_STREQ_LEN(written, buff, "1.7e+00");
}
TEST_F(LlvmLibcSPrintfTest, FloatAutoConv) {
- __llvm_libc::testutils::ForceRoundingMode r(
- __llvm_libc::testutils::RoundingMode::Nearest);
+ __llvm_libc::fputil::testing::ForceRoundingMode r(
+ __llvm_libc::fputil::testing::RoundingMode::Nearest);
double inf = __llvm_libc::fputil::FPBits<double>::inf().get_val();
double nan = __llvm_libc::fputil::FPBits<double>::build_nan(1);
// Rounding Mode Tests.
{
- __llvm_libc::testutils::ForceRoundingMode r(
- __llvm_libc::testutils::RoundingMode::Nearest);
+ __llvm_libc::fputil::testing::ForceRoundingMode r(
+ __llvm_libc::fputil::testing::RoundingMode::Nearest);
written = __llvm_libc::sprintf(buff, "%.2g", 1.75);
ASSERT_STREQ_LEN(written, buff, "1.8");
}
{
- __llvm_libc::testutils::ForceRoundingMode r(
- __llvm_libc::testutils::RoundingMode::Upward);
+ __llvm_libc::fputil::testing::ForceRoundingMode r(
+ __llvm_libc::fputil::testing::RoundingMode::Upward);
written = __llvm_libc::sprintf(buff, "%.2g", 1.75);
ASSERT_STREQ_LEN(written, buff, "1.8");
}
{
- __llvm_libc::testutils::ForceRoundingMode r(
- __llvm_libc::testutils::RoundingMode::Downward);
+ __llvm_libc::fputil::testing::ForceRoundingMode r(
+ __llvm_libc::fputil::testing::RoundingMode::Downward);
written = __llvm_libc::sprintf(buff, "%.2g", 1.75);
ASSERT_STREQ_LEN(written, buff, "1.7");
}
{
- __llvm_libc::testutils::ForceRoundingMode r(
- __llvm_libc::testutils::RoundingMode::TowardZero);
+ __llvm_libc::fputil::testing::ForceRoundingMode r(
+ __llvm_libc::fputil::testing::RoundingMode::TowardZero);
written = __llvm_libc::sprintf(buff, "%.2g", 1.75);
ASSERT_STREQ_LEN(written, buff, "1.7");