void main() { srand(time(0)); Stack ST; char c; // пока стек не заполнится while(!ST.IsFull()){ c=rand()%4+2; ST.Push(c); } // пока стек не освободится while(c=ST.Pop()){ cout<<c<<" "; } cout<<"\n\n"; }
Stack operator+(const Stack& s) const { // copy the first list Stack t = *this; Stack u = *this; Node *n = s.top; // iterate through the second list and copy each element to the new list while (n != NULL && !t.IsFull()) { t.Push(n->data); n = n->link; } n = t.top; while (n != NULL && !t.IsEmpty()) { u.Push(n->data); t.Pop(); n = t.top; } return u; }
TEST(Stack, isnt_full_stack_IsFull_0) { Stack<int> *S = new Stack<int>; S->Push(1); EXPECT_EQ(0, S->IsFull()); }
TEST(STACK, can_check_fullness) { Stack<int>* s = new Stack<int>; s->Push(5); EXPECT_EQ(0, s->IsFull()); }