Skip to content

Commit

Permalink
Adding assign(count, item) signature of assign. More to come to fin…
Browse files Browse the repository at this point in the history
…ish #55

Fixing #57. Breaking change but I doubt anybody is using these ctor signatures.
  • Loading branch information
thirtytwobits committed Sep 6, 2023
1 parent 1ed0110 commit 8431cd0
Show file tree
Hide file tree
Showing 7 changed files with 1,137 additions and 954 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,10 @@ TEST(example_08_variable_length_array_vs_vector, example_tight_fit_1)
cetl::pf17::pmr::UnsynchronizedArrayMemoryResource<56> array_storage_1{};
cetl::pf17::pmr::UnsynchronizedArrayMemoryResource<56> array_storage_0{&array_storage_1,
array_storage_1.max_size()};
cetl::VariableLengthArray<char, cetl::pf17::pmr::polymorphic_allocator<char>> tight_fit{{&array_storage_0},
array_storage_0.size()};
cetl::VariableLengthArray<char, cetl::pf17::pmr::polymorphic_allocator<char>> tight_fit{
array_storage_0.size(),
{&array_storage_0},
};
for (std::size_t i = 0; i < 56; ++i)
{
std::cout << i << ", ";
Expand All @@ -102,8 +104,10 @@ TEST(example_08_variable_length_array_vs_vector, example_exact_fit)
/// resource.

cetl::pf17::pmr::UnsynchronizedArrayMemoryResource<56> array_storage_0{};
cetl::VariableLengthArray<char, cetl::pf17::pmr::polymorphic_allocator<char>> exact_fit{{&array_storage_0},
array_storage_0.size()};
cetl::VariableLengthArray<char, cetl::pf17::pmr::polymorphic_allocator<char>> exact_fit{
array_storage_0.size(),
{&array_storage_0},
};
exact_fit.reserve(56);
for (std::size_t i = 0; i < 56; ++i)
{
Expand Down

This file was deleted.

24 changes: 24 additions & 0 deletions cetlvast/suites/unittest/test_variable_length_array_bool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -340,3 +340,27 @@ TYPED_TEST(VLABoolTests, TestBoolBack)
const_cast<typename std::add_pointer<typename std::add_const<decltype(array)>::type>::type>(&array)->back();
ASSERT_TRUE(value);
}

TYPED_TEST(VLABoolTests, TestAssignCountAndValue)
{
auto array = TypeParam::make_bool_container();
array.assign(0, true);
ASSERT_EQ(0, array.size());
array.assign(1, false);
ASSERT_EQ(1, array.size());
ASSERT_FALSE(array[0]);
array.resize(9, false);
ASSERT_EQ(9, array.size());
array.assign(3, false);
ASSERT_EQ(3, array.size());
for(auto i = array.begin(), e = array.end(); i != e; ++i)
{
ASSERT_FALSE(*i);
}
array.assign(17, true);
ASSERT_EQ(17, array.size());
for(auto i = array.begin(), e = array.end(); i != e; ++i)
{
ASSERT_TRUE(*i);
}
}
Loading

0 comments on commit 8431cd0

Please sign in to comment.