Skip to content

Commit f4e4769

Browse files
committed
Changed testing to accommodate C++11 better
1 parent e6f031a commit f4e4769

File tree

2 files changed

+50
-23
lines changed

2 files changed

+50
-23
lines changed

test/test_string_u16.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ namespace
306306
//*************************************************************************
307307
TEST_FIXTURE(SetupFixture, test_constructor_8bit_range)
308308
{
309-
etl::string_view text8Bit{"8-bit"};
309+
std::string text8Bit{"8-bit"};
310310
TextSTD compare_text(text8Bit.begin(), text8Bit.end());
311311

312312
Text text(text8Bit.begin(), text8Bit.end());
@@ -330,7 +330,7 @@ namespace
330330
//*************************************************************************
331331
TEST_FIXTURE(SetupFixture, test_constructor_8bit_const_range)
332332
{
333-
const std::array<char const, 6U> text8Bit{"8-bit"};
333+
std::array<char const, 6U> const text8Bit{"8-bit"};
334334
TextSTD compare_text(text8Bit.begin(), text8Bit.end());
335335

336336
Text text(text8Bit.begin(), text8Bit.end());
@@ -1251,9 +1251,9 @@ namespace
12511251
}
12521252

12531253
//*************************************************************************
1254-
TEST_FIXTURE(SetupFixture, test_assign_8bit_range)
1254+
TEST_FIXTURE(SetupFixture, test_assign_range_8bit)
12551255
{
1256-
etl::string_view text8Bit{"8-bit"};
1256+
std::string text8Bit{"8-bit"};
12571257

12581258
Text text;
12591259

@@ -1273,9 +1273,9 @@ namespace
12731273
}
12741274

12751275
//*************************************************************************
1276-
TEST_FIXTURE(SetupFixture, test_assign_8bit_const_range)
1276+
TEST_FIXTURE(SetupFixture, test_assign_range_8bit_const)
12771277
{
1278-
etl::string_view text8Bit{"8-bit"};
1278+
std::array<char const, 6U> const text8Bit{"8-bit"};
12791279

12801280
Text text;
12811281

test/test_string_u16_external_buffer.cpp

Lines changed: 44 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -431,20 +431,20 @@ namespace
431431
CHECK(isEqual);
432432
}
433433

434-
TEST_FIXTURE(SetupFixture, test_constructor_from_8bit_range)
434+
TEST_FIXTURE(SetupFixture, test_constructor_from_range_8bit)
435435
{
436-
etl::string_view view8Bit{"8-bit"};
436+
std::string text8Bit{"8-bit"};
437437
TextBuffer buffer{0};
438-
Text text(view8Bit.begin(), view8Bit.end(), buffer.data(), buffer.size());
438+
Text text(text8Bit.begin(), text8Bit.end(), buffer.data(), buffer.size());
439439

440-
CHECK_EQUAL(view8Bit.size(), text.size());
440+
CHECK_EQUAL(text8Bit.size(), text.size());
441441
CHECK_FALSE(text.empty());
442442
CHECK_FALSE(text.is_truncated());
443443

444444
bool isEqual = true;
445-
for (size_t i = 0U; i < view8Bit.size(); i++)
445+
for (size_t i = 0U; i < text8Bit.size(); i++)
446446
{
447-
if (text.at(i) != static_cast<Text::value_type>(view8Bit.at(i)))
447+
if (text.at(i) != static_cast<Text::value_type>(text8Bit.at(i)))
448448
{
449449
isEqual = false;
450450
break;
@@ -453,20 +453,20 @@ namespace
453453
CHECK(isEqual);
454454
}
455455

456-
TEST_FIXTURE(SetupFixture, test_constructor_from_8bit_const_range)
456+
TEST_FIXTURE(SetupFixture, test_constructor_from_range_8bit_const)
457457
{
458-
const std::array<char const, 6U> view8Bit{"8-bit"};
458+
std::array<char const, 6U> const text8Bit{"8-bit"};
459459
TextBuffer buffer{0};
460-
Text text(view8Bit.begin(), view8Bit.end(), buffer.data(), buffer.size());
460+
Text text(text8Bit.begin(), text8Bit.end(), buffer.data(), buffer.size());
461461

462-
CHECK_EQUAL(view8Bit.size(), text.size());
462+
CHECK_EQUAL(text8Bit.size(), text.size());
463463
CHECK_FALSE(text.empty());
464464
CHECK_FALSE(text.is_truncated());
465465

466466
bool isEqual = true;
467-
for (size_t i = 0U; i < view8Bit.size(); i++)
467+
for (size_t i = 0U; i < text8Bit.size(); i++)
468468
{
469-
if (text.at(i) != static_cast<Text::value_type>(view8Bit.at(i)))
469+
if (text.at(i) != static_cast<Text::value_type>(text8Bit.at(i)))
470470
{
471471
isEqual = false;
472472
break;
@@ -1469,22 +1469,49 @@ namespace
14691469
//*************************************************************************
14701470
TEST_FIXTURE(SetupFixture, test_assign_range_8bit)
14711471
{
1472-
constexpr etl::string_view u8Text{"8-bit"};
1472+
std::string text8Bit{"8-bit"};
14731473

14741474
TextBuffer buffer{0};
14751475
Text text(buffer.data(), buffer.size());
14761476

1477-
text.assign(u8Text.begin(), u8Text.end());
1477+
text.assign(text8Bit.begin(), text8Bit.end());
14781478

14791479
// bool is_equal = Equal(compare_text, text);
14801480
// CHECK(is_equal);
14811481
CHECK_FALSE(text.is_truncated());
1482-
CHECK_EQUAL(u8Text.size(), text.size());
1482+
CHECK_EQUAL(text8Bit.size(), text.size());
14831483

14841484
bool isEqual = true;
1485-
for (auto i = 0U; i < u8Text.size(); i++)
1485+
for (auto i = 0U; i < text8Bit.size(); i++)
14861486
{
1487-
if (text.at(i) != static_cast<Text::value_type>(u8Text.at(i)))
1487+
if (text.at(i) != static_cast<Text::value_type>(text8Bit.at(i)))
1488+
{
1489+
isEqual = false;
1490+
break;
1491+
}
1492+
}
1493+
CHECK(isEqual);
1494+
}
1495+
1496+
//*************************************************************************
1497+
TEST_FIXTURE(SetupFixture, test_assign_range_8bit_const)
1498+
{
1499+
std::array<char const, 6U> const text8Bit{"8-bit"};
1500+
1501+
TextBuffer buffer{0};
1502+
Text text(buffer.data(), buffer.size());
1503+
1504+
text.assign(text8Bit.begin(), text8Bit.end());
1505+
1506+
// bool is_equal = Equal(compare_text, text);
1507+
// CHECK(is_equal);
1508+
CHECK_FALSE(text.is_truncated());
1509+
CHECK_EQUAL(text8Bit.size(), text.size());
1510+
1511+
bool isEqual = true;
1512+
for (auto i = 0U; i < text8Bit.size(); i++)
1513+
{
1514+
if (text.at(i) != static_cast<Text::value_type>(text8Bit.at(i)))
14881515
{
14891516
isEqual = false;
14901517
break;

0 commit comments

Comments
 (0)