github.com/searKing/golang/go@v1.2.117/container/hashmap/hashmap_test.go (about)

     1  // Copyright 2020 The searKing Author. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package hashmap
     6  
     7  import "testing"
     8  
     9  func Test(t *testing.T) {
    10  	s := New()
    11  
    12  	if s.Len() != 0 {
    13  		t.Errorf("Length should be 0")
    14  	}
    15  	s.Remove(0)
    16  	s.Add(5, 5)
    17  
    18  	if s.Count() != 1 {
    19  		t.Errorf("Length should be 1")
    20  	}
    21  
    22  	if !s.Contains(5) {
    23  		t.Errorf("Contains test failed")
    24  	}
    25  
    26  	s.Remove(5)
    27  
    28  	if s.Count() != 0 {
    29  		t.Errorf("Length should be 0")
    30  	}
    31  
    32  	if s.Contains(5) {
    33  		t.Errorf("The set should be empty")
    34  	}
    35  }