Esempio n. 1
0
func TestAdd(t *testing.T) {
	syncMap := models.NewSynchronizedMap()
	syncMap.Add("new key", "new value")
	if syncMap.HasKey("new key") == false {
		t.Error("HasKey() should have returned true")
	}
}
Esempio n. 2
0
func TestGet(t *testing.T) {
	syncMap := models.NewSynchronizedMap()
	if syncMap.Get("does not exist") != "" {
		t.Error("Get() should have returned empty string")
	}
	syncMap.Add("new key", "new value")
	if syncMap.Get("new key") != "new value" {
		t.Error("Get() returned '%s' instead of 'new value'", syncMap.Get("new key"))
	}
}
Esempio n. 3
0
func TestDelete(t *testing.T) {
	syncMap := models.NewSynchronizedMap()
	syncMap.Add("new key", "new value")
	if syncMap.HasKey("new key") == false {
		t.Error("HasKey() should have returned true")
	}
	syncMap.Delete("new key")
	if syncMap.HasKey("new key") == true {
		t.Error("Delete() did not delete key 'new key'")
	}
}
Esempio n. 4
0
func TestValues(t *testing.T) {
	syncMap := models.NewSynchronizedMap()
	values := syncMap.Values()
	if len(values) != 0 {
		t.Error("Values() should have returned an empty list")
	}
	syncMap.Add("key 1", "value 1")
	syncMap.Add("key 2", "value 2")
	syncMap.Add("key 3", "value 3")
	values = syncMap.Values()
	if len(values) != 3 {
		t.Error("Values() should have returned 3 items")
	}
}
Esempio n. 5
0
func TestNew(t *testing.T) {
	syncMap := models.NewSynchronizedMap()
	if syncMap == nil {
		t.Error("NewSynchronizedMap() returned nil")
	}
}