github.com/Nigel2392/go-datastructures@v1.1.5/stack/stack_test.go (about)

     1  package stack_test
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/Nigel2392/go-datastructures/stack"
     7  )
     8  
     9  func TestStack(t *testing.T) {
    10  	var s = stack.Stack[int]{}
    11  	s.Push(1)
    12  	s.Push(2)
    13  	s.Push(3)
    14  	s.Push(4)
    15  	s.Push(5)
    16  	s.Push(6)
    17  	s.Push(7)
    18  	s.Push(8)
    19  	s.Push(9)
    20  	s.Push(10)
    21  
    22  	if s.Pop() != 10 {
    23  		t.Errorf("Expected 10, got %d", s.Pop())
    24  	}
    25  	if s.Pop() != 9 {
    26  		t.Errorf("Expected 9, got %d", s.Pop())
    27  	}
    28  	if s.Pop() != 8 {
    29  		t.Errorf("Expected 8, got %d", s.Pop())
    30  	}
    31  	if s.Pop() != 7 {
    32  		t.Errorf("Expected 7, got %d", s.Pop())
    33  	}
    34  	if s.Pop() != 6 {
    35  		t.Errorf("Expected 6, got %d", s.Pop())
    36  	}
    37  	if s.Pop() != 5 {
    38  		t.Errorf("Expected 5, got %d", s.Pop())
    39  	}
    40  	if s.Pop() != 4 {
    41  		t.Errorf("Expected 4, got %d", s.Pop())
    42  	}
    43  	if s.Pop() != 3 {
    44  		t.Errorf("Expected 3, got %d", s.Pop())
    45  	}
    46  	if s.Pop() != 2 {
    47  		t.Errorf("Expected 2, got %d", s.Pop())
    48  	}
    49  	if s.Pop() != 1 {
    50  		t.Errorf("Expected 1, got %d", s.Pop())
    51  	}
    52  }