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));
59double _doTestDouble(
double value)
61 std::cout <<
"ValueDirectStream=" << value <<
"\n";
62 std::ostringstream ostr;
63 ostr << value <<
"\n";
64 std::string str0 = ostr.str();
65 std::cout <<
"O_STR=" << str0;
68 std::istringstream istr(str0);
70 std::cout <<
"IS_GOOD?=" << istr.good() <<
"\n";
72 std::cout <<
"IS_GOOD?=" << istr.good() <<
"\n";
73 std::cout <<
"V=" << v <<
"\n";
74 char* str_end =
nullptr;
75 double v2 = std::strtod(str0.data(), &str_end);
76 std::cout <<
"ReadWith 'strtod' =" << v2 <<
"\n";
81 auto [ptr, ec] = std::from_chars(str0.data(), str0.data() + str0.length(), result);
82 if (ec == std::errc())
83 std::cout <<
"Result: " << result <<
", ptr -> " << (ptr - str0.data()) <<
'\n';
84 else if (ec == std::errc::invalid_argument)
85 std::cout <<
"This is not a number.\n";
86 else if (ec == std::errc::result_out_of_range)
87 std::cout <<
"This number is larger than an int.\n";
94TEST(TestFromChars, Real)
96 std::cout <<
"TEST_ValueConvert 'Real' \n";
97 double d_inf = std::numeric_limits<double>::infinity();
98 double d_nan = std::numeric_limits<double>::quiet_NaN();
99 std::cout <<
"Infinity=" << d_inf <<
"\n";
100 std::cout <<
"NaN=" << d_nan <<
"\n";
102 double d_t0 = 1.2345;
103 std::cout <<
"** Test: " << d_t0 <<
"\n";
104 double r_t0 = _doTestDouble(d_t0);
105 ASSERT_EQ(r_t0, d_t0);
107 std::cout <<
"** Test: Infinity\n";
108 double r_inf = _doTestDouble(d_inf);
109 ASSERT_EQ(r_inf, d_inf);
111 std::cout <<
"** Test: NaN\n";
112 double r_nan = _doTestDouble(d_nan);
#define ASSERT_TRUE(condition)
Vérifie que condition est vrai.
Espace de nom pour l'utilisation des accélérateurs.
@ Atomic
Utilise des opérations atomiques entre les blocs.
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-