Skip to content

Commit

Permalink
Merge
Browse files Browse the repository at this point in the history
  • Loading branch information
John Wellbelove committed May 28, 2024
1 parent bbfce66 commit 57aaa11
Show file tree
Hide file tree
Showing 3 changed files with 165 additions and 0 deletions.
55 changes: 55 additions & 0 deletions test/test_string_u16_external_buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,61 @@ namespace
#endif
}

//*************************************************************************
TEST_FIXTURE(SetupFixture, test_move_constructor_move_the_string)
{
TextBuffer buffer1{ 0 };
Text text(initial_text.c_str(), buffer1.data(), buffer1.size());

size_t original_size = text.size();
size_t original_max_size = text.max_size();

TextBuffer buffer2{ 0 };
Text text2(etl::move(text), buffer2.data(), buffer2.size());

// Check the source string.
CHECK_TRUE(text.empty());
CHECK_FALSE(text.full());
CHECK_EQUAL(0U, text.size());
CHECK_EQUAL(original_max_size, text.max_size());
CHECK_TRUE(text.data() != nullptr);

// Check the destination string.
CHECK_FALSE(text2.empty());
CHECK_TRUE(text2.full());
CHECK_EQUAL(original_size, text2.size());
CHECK_EQUAL(original_max_size, text2.max_size());
CHECK_TRUE(text2.data() != nullptr);
CHECK_TRUE(std::equal(initial_text.begin(), initial_text.end(), text2.begin()));
}

//*************************************************************************
TEST_FIXTURE(SetupFixture, test_move_constructor_steal_the_string)
{
TextBuffer buffer{ 0 };
Text text(initial_text.c_str(), buffer.data(), buffer.size());

size_t original_size = text.size();
size_t original_max_size = text.max_size();

Text text2(etl::move(text));

// Check the source string.
CHECK_TRUE(text.empty());
CHECK_TRUE(text.full());
CHECK_EQUAL(0U, text.size());
CHECK_EQUAL(0U, text.max_size());
CHECK_TRUE(text.data() == nullptr);

// Check the destination string.
CHECK_FALSE(text2.empty());
CHECK_TRUE(text2.full());
CHECK_EQUAL(original_size, text2.size());
CHECK_EQUAL(original_max_size, text2.max_size());
CHECK_TRUE(text2.data() != nullptr);
CHECK_TRUE(std::equal(initial_text.begin(), initial_text.end(), text2.begin()));
}

//*************************************************************************
TEST_FIXTURE(SetupFixture, test_construct_position_length)
{
Expand Down
55 changes: 55 additions & 0 deletions test/test_string_u32_external_buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,61 @@ namespace
#endif
}

//*************************************************************************
TEST_FIXTURE(SetupFixture, test_move_constructor_move_the_string)
{
TextBuffer buffer1{ 0 };
Text text(initial_text.c_str(), buffer1.data(), buffer1.size());

size_t original_size = text.size();
size_t original_max_size = text.max_size();

TextBuffer buffer2{ 0 };
Text text2(etl::move(text), buffer2.data(), buffer2.size());

// Check the source string.
CHECK_TRUE(text.empty());
CHECK_FALSE(text.full());
CHECK_EQUAL(0U, text.size());
CHECK_EQUAL(original_max_size, text.max_size());
CHECK_TRUE(text.data() != nullptr);

// Check the destination string.
CHECK_FALSE(text2.empty());
CHECK_TRUE(text2.full());
CHECK_EQUAL(original_size, text2.size());
CHECK_EQUAL(original_max_size, text2.max_size());
CHECK_TRUE(text2.data() != nullptr);
CHECK_TRUE(std::equal(initial_text.begin(), initial_text.end(), text2.begin()));
}

//*************************************************************************
TEST_FIXTURE(SetupFixture, test_move_constructor_steal_the_string)
{
TextBuffer buffer{ 0 };
Text text(initial_text.c_str(), buffer.data(), buffer.size());

size_t original_size = text.size();
size_t original_max_size = text.max_size();

Text text2(etl::move(text));

// Check the source string.
CHECK_TRUE(text.empty());
CHECK_TRUE(text.full());
CHECK_EQUAL(0U, text.size());
CHECK_EQUAL(0U, text.max_size());
CHECK_TRUE(text.data() == nullptr);

// Check the destination string.
CHECK_FALSE(text2.empty());
CHECK_TRUE(text2.full());
CHECK_EQUAL(original_size, text2.size());
CHECK_EQUAL(original_max_size, text2.max_size());
CHECK_TRUE(text2.data() != nullptr);
CHECK_TRUE(std::equal(initial_text.begin(), initial_text.end(), text2.begin()));
}

//*************************************************************************
TEST_FIXTURE(SetupFixture, test_construct_position_length)
{
Expand Down
55 changes: 55 additions & 0 deletions test/test_string_u8_external_buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,61 @@ namespace
#endif
}

//*************************************************************************
TEST_FIXTURE(SetupFixture, test_move_constructor_move_the_string)
{
TextBuffer buffer1{ 0 };
Text text(initial_text.c_str(), buffer1.data(), buffer1.size());

size_t original_size = text.size();
size_t original_max_size = text.max_size();

TextBuffer buffer2{ 0 };
Text text2(etl::move(text), buffer2.data(), buffer2.size());

// Check the source string.
CHECK_TRUE(text.empty());
CHECK_FALSE(text.full());
CHECK_EQUAL(0U, text.size());
CHECK_EQUAL(original_max_size, text.max_size());
CHECK_TRUE(text.data() != nullptr);

// Check the destination string.
CHECK_FALSE(text2.empty());
CHECK_TRUE(text2.full());
CHECK_EQUAL(original_size, text2.size());
CHECK_EQUAL(original_max_size, text2.max_size());
CHECK_TRUE(text2.data() != nullptr);
CHECK_TRUE(std::equal(initial_text.begin(), initial_text.end(), text2.begin()));
}

//*************************************************************************
TEST_FIXTURE(SetupFixture, test_move_constructor_steal_the_string)
{
TextBuffer buffer{ 0 };
Text text(initial_text.c_str(), buffer.data(), buffer.size());

size_t original_size = text.size();
size_t original_max_size = text.max_size();

Text text2(etl::move(text));

// Check the source string.
CHECK_TRUE(text.empty());
CHECK_TRUE(text.full());
CHECK_EQUAL(0U, text.size());
CHECK_EQUAL(0U, text.max_size());
CHECK_TRUE(text.data() == nullptr);

// Check the destination string.
CHECK_FALSE(text2.empty());
CHECK_TRUE(text2.full());
CHECK_EQUAL(original_size, text2.size());
CHECK_EQUAL(original_max_size, text2.max_size());
CHECK_TRUE(text2.data() != nullptr);
CHECK_TRUE(std::equal(initial_text.begin(), initial_text.end(), text2.begin()));
}

//*************************************************************************
TEST_FIXTURE(SetupFixture, test_construct_position_length)
{
Expand Down

0 comments on commit 57aaa11

Please sign in to comment.