You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

69 lines
2.5 KiB

#include "ft_container.hpp"
// debugs:
//
void test_vectors(void) {
ft::vector< int > test1 = ft::vector< int >();
ft::vector< int > test2 = ft::vector< int >(10);
ft::vector< int > test3 = ft::vector< int >(10, 4);
ft::vector< int > test4 = ft::vector< int >(test3.begin(), test3.begin() + 4);
ft::vector< int > test5 = ft::vector< int >(test3);
std::cout << "1) vector<int>() | ";
test1.print();
std::cout << "2) vector<int>(10) | ";
test2.print();
std::cout << "3) vector<int>(10, 4) | ";
test3.print();
std::cout << "4) vector<int>(test3.begin(), test3.begin() + 4) | ";
test4.print();
std::cout << "5.a) vector<int>(test3) | ";
test5.print();
ft::vector< int >::reference test5_begin = *test5.begin();
std::cout << "5.b) test5_begin = *test5.begin() | " << test5_begin
<< std::endl;
test5 = test4;
std::cout << "\ttest5 = test4 | ";
test5.print();
std::cout << "\ttest5_begin | " << test5_begin << std::endl;
std::cout << "6.a) test5.assign(2,2) | ";
test5.assign(2, 2);
test5.print();
std::cout << "6.b) test5.assign(test3.begin(), test3.begin() + 4) | ";
test5.assign(test3.begin(), test3.begin() + 4);
test5.print();
std::cout << "7.a) test5.at(0) | " << test5.at(0) << std::endl;
std::cout << "7.b) test5.at(4) | " << test5.at(4) << std::endl;
std::cout << "7.c) test5.at(5) | ";
try {
std::cout << test5.at(5) << std::endl;
} catch (std::exception &e) {
std::cout << e.what() << std::endl;
}
std::cout << "8.a) test5[4] = 1; | " << (test5[4] = 1) << std::endl;
std::cout << "8.b) test5[0] | " << test5[0] << std::endl;
std::cout << "8.c) test5[4] | " << test5[4] << std::endl;
std::cout << "9.a) test5.front() | " << test5.front() << std::endl;
std::cout << "9.b) test5.back() | " << test5.back() << std::endl;
std::cout << "10.a) *test5.data() | " << *test5.data() << std::endl;
std::cout << "11.a) test5.empty() | " << test5.empty() << std::endl;
std::cout << "11.b) test5.size() | " << test5.size() << std::endl;
std::cout << "11.c) test5.max_size() | " << test5.max_size() << std::endl;
std::cout << "11.d) test5.capacity() | " << test5.capacity() << std::endl;
test5.resize(0);
std::cout << "12.a) test5.resize(0) : "<< std::endl;
std::cout << "12.b) test5.empty() | " << test5.empty() << std::endl;
std::cout << "12.c) test5.size() | " << test5.size() << std::endl;
std::cout << "12.d) test5.max_size() | " << test5.max_size() << std::endl;
std::cout << "12.e) test5.capacity() | " << test5.capacity() << std::endl;
}
int main(void) { test_vectors(); }