void test_const_rand_acc_iter_const() { dynArray<int> const test { 1, 2, 3, 4, 5, 6, 7, 8, 6 }; int erg { std::accumulate(test.cbegin(), test.cend(), 0) }; ASSERT_EQUAL(42, erg); }
void testReverseIterConst() { std::ostringstream out { }; std::ostream_iterator<char> const out_iter(out, ""); dynArray<char> const test { 'o', 'l', 'l', 'a', 'h' }; std::copy(test.rbegin(), test.rend(), out_iter); ASSERT_EQUAL("hallo", out.str()); }
void test_rev_iter_const() { std::ostringstream out { }; std::ostream_iterator<int> out_iter(out, ""); dynArray<int> const test { 2, 4 }; std::copy(test.rbegin(), test.rend(), out_iter); ASSERT_EQUAL("42", out.str()); }
void test_rand_acc_iter_const() { std::ostringstream out { }; std::ostream_iterator<std::string> out_iter(out, " "); dynArray<std::string> const test { "42", "is", "always", "the", "answer" }; std::copy(test.begin(), test.end(), out_iter); ASSERT_EQUAL("42 is always the answer ", out.str()); }
dynArray dynArray::operator =(dynArray &right) { ensuresize(right.nelements); nelements=right.nelements; for(int i=0;i<nelements;i++) { this->elems[i]=right.getelem(i); } curmax=right.curmax; return *this; }
void test_at_func_const() { dynArray<int> const test { 1, 3, 5, 42, 9 }; ASSERT_EQUAL(42, test.at(3)); }
void test_func_back_const() { dynArray<std::string> const test { "hello", "what's", "up" }; ASSERT_EQUAL("up", test.back()); }
void test_func_front_const() { dynArray<double> const test { 42.0, 2.0, 3.0, 4.0 }; ASSERT_EQUAL(42.0, test.front()); }
void testBackConst() { std::vector<int> const iu { 1, 2, 5 }; dynArray<int> const dyniu { 1, 2, 5 }; ASSERT_EQUAL(iu.back(), dyniu.back()); }
void testFrontConst() { std::vector<int> const iu { 1, 2, 5 }; dynArray<int> const dyniu { 1, 2, 5 }; ASSERT_EQUAL(iu.front(), dyniu.front()); }