mirror of
https://github.com/astaxie/beego.git
synced 2024-11-22 12:40:55 +00:00
Rewrite safemap_test suite
This commit is contained in:
parent
d736d0ca87
commit
75ec8d33a2
@ -14,25 +14,44 @@
|
||||
|
||||
package utils
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
import "testing"
|
||||
|
||||
func Test_beemap(t *testing.T) {
|
||||
bm := NewBeeMap()
|
||||
if !bm.Set("astaxie", 1) {
|
||||
t.Error("set Error")
|
||||
var safeMap *BeeMap
|
||||
|
||||
func TestNewBeeMap(t *testing.T) {
|
||||
safeMap = NewBeeMap()
|
||||
if safeMap == nil {
|
||||
t.Fatal("expected to return non-nil BeeMap", "got", safeMap)
|
||||
}
|
||||
if !bm.Check("astaxie") {
|
||||
t.Error("check err")
|
||||
}
|
||||
|
||||
if v := bm.Get("astaxie"); v.(int) != 1 {
|
||||
t.Error("get err")
|
||||
func TestSet(t *testing.T) {
|
||||
if ok := safeMap.Set("astaxie", 1); !ok {
|
||||
t.Error("expected", true, "got", false)
|
||||
}
|
||||
}
|
||||
|
||||
bm.Delete("astaxie")
|
||||
if bm.Check("astaxie") {
|
||||
t.Error("delete err")
|
||||
func TestCheck(t *testing.T) {
|
||||
if exists := safeMap.Check("astaxie"); !exists {
|
||||
t.Error("expected", true, "got", false)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGet(t *testing.T) {
|
||||
if val := safeMap.Get("astaxie"); val.(int) != 1 {
|
||||
t.Error("expected value", 1, "got", val)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDelete(t *testing.T) {
|
||||
safeMap.Delete("astaxie")
|
||||
if exists := safeMap.Check("astaxie"); exists {
|
||||
t.Error("expected element to be deleted")
|
||||
}
|
||||
}
|
||||
|
||||
func TestCount(t *testing.T) {
|
||||
if count := safeMap.Count(); count != 0 {
|
||||
t.Error("expected count to be", 0, "got", count)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user