55 lines
775 B
Go
55 lines
775 B
Go
package dict
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestNew(t *testing.T) {
|
|
d := New()
|
|
if d == nil {
|
|
t.Error("New() should not return nil")
|
|
}
|
|
if len(d) != 0 {
|
|
t.Errorf("New() should return an empty dict, got %v", d)
|
|
}
|
|
}
|
|
|
|
func TestIsDict(t *testing.T) {
|
|
d := Dict{
|
|
"key1": "value1",
|
|
}
|
|
|
|
r := IsDict(d)
|
|
if !r {
|
|
t.Errorf("Expected true, got %v", r)
|
|
}
|
|
|
|
r = IsDict(12)
|
|
if r {
|
|
t.Errorf("Expected false, got %v", r)
|
|
}
|
|
|
|
r = IsDict("Cool!")
|
|
if r {
|
|
t.Errorf("Expected false, got %v", r)
|
|
}
|
|
|
|
var v1 interface{}
|
|
r = IsDict(v1)
|
|
if r {
|
|
t.Errorf("Expected false, got %v", r)
|
|
}
|
|
|
|
var v2 []interface{}
|
|
r = IsDict(v2)
|
|
if r {
|
|
t.Errorf("Expected false, got %v", r)
|
|
}
|
|
|
|
var v3 map[string]interface{}
|
|
r = IsDict(v3)
|
|
if r {
|
|
t.Errorf("Expected false, got %v", r)
|
|
}
|
|
}
|