34 lines
918 B
C++
34 lines
918 B
C++
#include <cruft/util/tap.hpp>
|
|
#include <cruft/util/array/darray.hpp>
|
|
|
|
int
|
|
main (int, char**)
|
|
{
|
|
cruft::TAP::logger tap;
|
|
|
|
cruft::darray<8,int> val ({ 0, 1, 2, 3, 4, 5, 6, 7});
|
|
|
|
tap.expect_eq (val.size (), 8u, "query for size");
|
|
|
|
tap.expect_eq (val.capacity (), decltype(val)::elements, "static vs dynamic query for capacity");
|
|
|
|
{
|
|
auto const sum = std::accumulate (val.cbegin (), val.cend (), 0u);
|
|
tap.expect_eq (sum, 28u, "accumulate over initializer_list range");
|
|
}
|
|
|
|
{
|
|
val.erase (val.begin () + 2);
|
|
tap.expect_eq (val.size (), 7u, "erasing removes one element");
|
|
|
|
auto const sum = std::accumulate (val.cbegin (), val.cend (), 0u);
|
|
tap.expect_eq (sum, 26u, "erase one element");
|
|
}
|
|
|
|
{
|
|
val.insert (val.begin () + 4, 9);
|
|
tap.expect_eq (val[5], 9, "inserted values matches indexed value");
|
|
}
|
|
|
|
return tap.status ();
|
|
} |