8#include <gtest/gtest.h>
10#include "arcane/utils/ArcaneCxx20.h"
29 std::atomic_ref<Int32>
ax(x);
39template <
integral DataType> DataType _testAdd(DataType a, DataType b)
45TEST(TestCxx20, Concept)
49 ASSERT_EQ(_testAdd(a, b), (a + b));
58double _doTestDouble(
double value)
60 std::cout <<
"ValueDirectStream=" << value <<
"\n";
61 std::ostringstream ostr;
62 ostr << value <<
"\n";
63 std::string str0 = ostr.str();
64 std::cout <<
"O_STR=" << str0;
67 std::istringstream istr(str0);
69 std::cout <<
"IS_GOOD?=" << istr.good() <<
"\n";
71 std::cout <<
"IS_GOOD?=" << istr.good() <<
"\n";
72 std::cout <<
"V=" << v <<
"\n";
73 char* str_end =
nullptr;
74 double v2 = std::strtod(str0.data(), &str_end);
75 std::cout <<
"ReadWith 'strtod' =" << v2 <<
"\n";
80 auto [ptr, ec] = std::from_chars(str0.data(), str0.data() + str0.length(), result);
81 if (ec == std::errc())
82 std::cout <<
"Result: " << result <<
", ptr -> " << (ptr - str0.data()) <<
'\n';
83 else if (ec == std::errc::invalid_argument)
84 std::cout <<
"This is not a number.\n";
85 else if (ec == std::errc::result_out_of_range)
86 std::cout <<
"This number is larger than an int.\n";
93TEST(TestFromChars, Real)
95 std::cout <<
"TEST_ValueConvert 'Real' \n";
96 double d_inf = std::numeric_limits<double>::infinity();
97 double d_nan = std::numeric_limits<double>::quiet_NaN();
98 std::cout <<
"Infinity=" << d_inf <<
"\n";
99 std::cout <<
"NaN=" << d_nan <<
"\n";
101 double d_t0 = 1.2345;
102 std::cout <<
"** Test: " << d_t0 <<
"\n";
103 double r_t0 = _doTestDouble(d_t0);
104 ASSERT_EQ(r_t0, d_t0);
106 std::cout <<
"** Test: Infinity\n";
107 double r_inf = _doTestDouble(d_inf);
108 ASSERT_EQ(r_inf, d_inf);
110 std::cout <<
"** Test: NaN\n";
111 double r_nan = _doTestDouble(d_nan);
#define ASSERT_TRUE(condition)
Checks that condition is true.
Namespace for accelerator usage.
@ Atomic
Uses atomic operations between blocks.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --