#include #include #include int main() { { MutantStack stack; assert(stack.begin() == stack.end()); stack.push(1); assert(*stack.begin() == 1); assert(*(stack.end() - 1) == 1); stack.push(2); stack.push(3); assert(*stack.begin() == 1); assert(*(stack.end() - 1) == 3); stack.pop(); assert(*stack.begin() == 1); assert(*(stack.end() - 1) == 2); MutantStack::iterator begin = stack.begin(); MutantStack::iterator end = stack.end() - 1; assert(*begin == 1); assert(*end == 2); begin++; assert(*begin == 2); assert(begin == end); end--; assert(*end == 1); } { MutantStack stack; assert(stack.begin() == stack.end()); stack.push("Hello"); assert(*stack.begin() == "Hello"); assert(*(stack.end() - 1) == "Hello"); stack.push("World"); stack.push("!"); assert(*stack.begin() == "Hello"); assert(*(stack.end() - 1) == "!"); stack.pop(); assert(*stack.begin() == "Hello"); assert(*(stack.end() - 1) == "World"); MutantStack::iterator begin = stack.begin(); MutantStack::iterator end = stack.end() - 1; assert(*begin == "Hello"); assert(*end == "World"); begin++; assert(*begin == "World"); assert(begin == end); end--; assert(*end == "Hello"); } }