Skip to content

Commit 4cd3337

Browse files
[arcane,utils] Ajoute test lecture des 'Real3' comme les 'Real'.
1 parent 2689acd commit 4cd3337

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

arcane/src/arcane/utils/tests/TestValueConvert.cc

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,21 @@ void _checkReal2(const String& s, Real2 expected_v)
7979
}
8080
}
8181

82+
void _checkReal3(const String& s, Real3 expected_v)
83+
{
84+
Real3 v = {};
85+
bool is_bad = builtInGetValue(v, s);
86+
std::cout << "S=" << s << " Real3=" << v << " is_bad?=" << is_bad << "\n";
87+
ASSERT_FALSE(is_bad) << "Can not convert '" << s << "' to Real3";
88+
bool do_test = false;
89+
_checkValidDouble(v.x, expected_v.x);
90+
_checkValidDouble(v.y, expected_v.y);
91+
_checkValidDouble(v.z, expected_v.z);
92+
if (do_test) {
93+
ASSERT_EQ(v, expected_v);
94+
}
95+
}
96+
8297
void _testDoubleConvert(bool use_from_chars)
8398
{
8499

@@ -96,6 +111,8 @@ void _testDoubleConvert(bool use_from_chars)
96111
_checkBad<double>("");
97112
_checkDouble("-0x1.81e03f705857bp-16", -2.3e-05);
98113
_checkDouble("0x1.81e03f705857bp-16", 2.3e-05);
114+
if (!use_from_chars)
115+
_checkDouble("+1.23e42", 1.23e42);
99116
_checkBad<double>("d2");
100117
_checkBad<double>("2.3w");
101118

@@ -146,6 +163,26 @@ void _testReal2Convert(bool use_same_that_real)
146163
_checkBad<Real2>(" y2.3 1.2");
147164
}
148165

166+
void _testReal3Convert(bool use_same_that_real)
167+
{
168+
impl::arcaneSetUseSameValueConvertForAllReal(use_same_that_real);
169+
Real v_nan = std::numeric_limits<double>::quiet_NaN();
170+
Real v_inf = std::numeric_limits<double>::infinity();
171+
_checkReal3("2.3e1 -1.2 1.5", Real3(2.3e1, -1.2, 1.5));
172+
if (use_same_that_real) {
173+
_checkReal3("-1.3 nan 4.6", Real3(-1.3, v_nan, 4.6));
174+
_checkReal3("1.3 4.2 inf", Real3(1.3, 4.2, v_inf));
175+
_checkReal3("-2.1 -1.5 1.0e5", Real3(-2.1, -1.5, 1.0e5));
176+
//_checkReal3("-2.1 -1.5 +1.0e5", Real3(-2.1, -1.5, 1.0e5));
177+
}
178+
_checkBad<Real3>("2.3 1.2w");
179+
_checkBad<Real3>("2.3x");
180+
_checkBad<Real3>("2.3 1.2");
181+
_checkBad<Real3>("2.3 -1.2ee2 4.5");
182+
_checkBad<Real3>("z2.3 -1.2e2 -2323.3");
183+
_checkBad<Real3>("2.3 -1.2e2 -2323.3x");
184+
}
185+
149186
/*---------------------------------------------------------------------------*/
150187
/*---------------------------------------------------------------------------*/
151188

@@ -164,12 +201,16 @@ TEST(ValueConvert, Basic)
164201
_testDoubleConvert(true);
165202
_testReal2Convert(true);
166203
_testReal2Convert(false);
204+
_testReal3Convert(true);
205+
_testReal3Convert(false);
167206
#endif
168207

169208
impl::arcaneSetIsValueConvertUseFromChars(false);
170209
_testDoubleConvert(false);
171210
_testReal2Convert(true);
172211
_testReal2Convert(false);
212+
_testReal3Convert(true);
213+
_testReal3Convert(false);
173214
}
174215

175216
TEST(ValueConvert, TryParse)

0 commit comments

Comments
 (0)