|
|
|
@ -30,3 +30,31 @@ CYBOZU_TEST_AUTO(resize) |
|
|
|
|
CYBOZU_TEST_EQUAL(b.size(), large); |
|
|
|
|
CYBOZU_TEST_EQUAL_ARRAY(a.data(), b.data(), small); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
CYBOZU_TEST_AUTO(FixedArray) |
|
|
|
|
{ |
|
|
|
|
const size_t n = 5; |
|
|
|
|
mcl::FixedArray<int, n> a, b; |
|
|
|
|
CYBOZU_TEST_EQUAL(a.size(), 0); |
|
|
|
|
CYBOZU_TEST_EQUAL(b.size(), 0); |
|
|
|
|
|
|
|
|
|
bool ok = a.resize(n); |
|
|
|
|
CYBOZU_TEST_ASSERT(ok); |
|
|
|
|
CYBOZU_TEST_EQUAL(n, a.size()); |
|
|
|
|
for (size_t i = 0; i < n; i++) { |
|
|
|
|
a[i] = i; |
|
|
|
|
} |
|
|
|
|
ok = b.copy(a); |
|
|
|
|
CYBOZU_TEST_ASSERT(ok); |
|
|
|
|
CYBOZU_TEST_EQUAL(b.size(), n); |
|
|
|
|
CYBOZU_TEST_EQUAL_ARRAY(a.data(), b.data(), n); |
|
|
|
|
|
|
|
|
|
const size_t small = n - 1; |
|
|
|
|
ok = b.resize(small); |
|
|
|
|
CYBOZU_TEST_ASSERT(ok); |
|
|
|
|
CYBOZU_TEST_EQUAL(b.size(), small); |
|
|
|
|
CYBOZU_TEST_EQUAL_ARRAY(a.data(), b.data(), small); |
|
|
|
|
const size_t large = n + 1; |
|
|
|
|
ok = b.resize(large); |
|
|
|
|
CYBOZU_TEST_ASSERT(!ok); |
|
|
|
|
} |
|
|
|
|