1
+ #include " fly/traits/traits.hpp"
1
2
#include " fly/types/numeric/literals.hpp"
2
3
#include " fly/types/string/string.hpp"
3
4
@@ -54,12 +55,8 @@ CATCH_TEMPLATE_TEST_CASE(
54
55
{
55
56
using StringType = TestType;
56
57
using BasicString = fly::BasicString<StringType>;
57
- using BasicStringTraits = fly::detail::BasicStringTraits<StringType>;
58
58
using char_type = typename BasicString::char_type;
59
59
using codepoint_type = typename BasicString::codepoint_type;
60
- using streamed_type = typename BasicString::streamed_type;
61
- using streamed_char = typename streamed_type::value_type;
62
- using ustreamed_char = std::make_unsigned_t <streamed_char>;
63
60
64
61
auto out_of_range_codepoint = []() -> StringType
65
62
{
@@ -185,64 +182,6 @@ CATCH_TEMPLATE_TEST_CASE(
185
182
}
186
183
}
187
184
188
- CATCH_SECTION (" Convert a string to a Boolean" )
189
- {
190
- StringType s;
191
-
192
- s = FLY_STR (char_type, " 0" );
193
- CATCH_CHECK (BasicString::template convert<bool >(s) == false );
194
-
195
- s = FLY_STR (char_type, " 1" );
196
- CATCH_CHECK (BasicString::template convert<bool >(s) == true );
197
-
198
- s = FLY_STR (char_type, " -1" );
199
- CATCH_CHECK_FALSE (BasicString::template convert<bool >(s));
200
-
201
- s = FLY_STR (char_type, " 2" );
202
- CATCH_CHECK_FALSE (BasicString::template convert<bool >(s));
203
-
204
- s = FLY_STR (char_type, " abc" );
205
- CATCH_CHECK_FALSE (BasicString::template convert<bool >(s));
206
-
207
- s = FLY_STR (char_type, " 2a" );
208
- CATCH_CHECK_FALSE (BasicString::template convert<bool >(s));
209
- }
210
-
211
- CATCH_SECTION (" Convert a string to a streamable character type" )
212
- {
213
- StringType s;
214
-
215
- s = FLY_STR (char_type, " 0" );
216
- CATCH_CHECK (BasicString::template convert<streamed_char>(s) == ' \0 ' );
217
- CATCH_CHECK (BasicString::template convert<ustreamed_char>(s) == ' \0 ' );
218
-
219
- s = FLY_STR (char_type, " 65" );
220
- CATCH_CHECK (BasicString::template convert<streamed_char>(s) == ' A' );
221
- CATCH_CHECK (
222
- BasicString::template convert<ustreamed_char>(s) == static_cast <ustreamed_char>(65 ));
223
-
224
- s = FLY_STR (char_type, " abc" );
225
- CATCH_CHECK_FALSE (BasicString::template convert<streamed_char>(s));
226
- CATCH_CHECK_FALSE (BasicString::template convert<ustreamed_char>(s));
227
-
228
- s = FLY_STR (char_type, " 2a" );
229
- CATCH_CHECK_FALSE (BasicString::template convert<streamed_char>(s));
230
- CATCH_CHECK_FALSE (BasicString::template convert<ustreamed_char>(s));
231
-
232
- if constexpr (BasicStringTraits::has_stoi_family_v)
233
- {
234
- CATCH_CHECK_FALSE (
235
- BasicString::template convert<streamed_char>(minstr<StringType, streamed_char>()));
236
- CATCH_CHECK_FALSE (
237
- BasicString::template convert<streamed_char>(maxstr<StringType, streamed_char>()));
238
-
239
- CATCH_CHECK_FALSE (BasicString::template convert<ustreamed_char>(
240
- minstr<StringType, ustreamed_char>()));
241
- CATCH_CHECK_FALSE (BasicString::template convert<ustreamed_char>(
242
- maxstr<StringType, ustreamed_char>()));
243
- }
244
- }
245
-
246
185
CATCH_SECTION (" Convert a string to an 8-bit integer" )
247
186
{
248
187
StringType s;
@@ -267,7 +206,7 @@ CATCH_TEMPLATE_TEST_CASE(
267
206
CATCH_CHECK_FALSE (BasicString::template convert<std::int8_t >(s));
268
207
CATCH_CHECK_FALSE (BasicString::template convert<std::uint8_t >(s));
269
208
270
- if constexpr (BasicStringTraits::has_stoi_family_v )
209
+ if constexpr (fly::any_same_v<char_type, char , wchar_t > )
271
210
{
272
211
CATCH_CHECK_FALSE (
273
212
BasicString::template convert<std::int8_t >(minstr<StringType, std::int8_t >()));
@@ -305,7 +244,7 @@ CATCH_TEMPLATE_TEST_CASE(
305
244
CATCH_CHECK_FALSE (BasicString::template convert<std::int16_t >(s));
306
245
CATCH_CHECK_FALSE (BasicString::template convert<std::uint16_t >(s));
307
246
308
- if constexpr (BasicStringTraits::has_stoi_family_v )
247
+ if constexpr (fly::any_same_v<char_type, char , wchar_t > )
309
248
{
310
249
CATCH_CHECK_FALSE (
311
250
BasicString::template convert<std::int16_t >(minstr<StringType, std::int16_t >()));
@@ -343,7 +282,7 @@ CATCH_TEMPLATE_TEST_CASE(
343
282
CATCH_CHECK_FALSE (BasicString::template convert<std::int32_t >(s));
344
283
CATCH_CHECK_FALSE (BasicString::template convert<std::uint32_t >(s));
345
284
346
- if constexpr (BasicStringTraits::has_stoi_family_v )
285
+ if constexpr (fly::any_same_v<char_type, char , wchar_t > )
347
286
{
348
287
CATCH_CHECK_FALSE (
349
288
BasicString::template convert<std::int32_t >(minstr<StringType, std::int32_t >()));
0 commit comments