|
|
|
@ -119,3 +119,233 @@ func TestStorePointerToStruct(t *testing.T) {
|
|
|
|
|
t.Fatal("TestStruct.Num is not 2")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestIncrementUint(t *testing.T) {
|
|
|
|
|
tc := New(0, 0)
|
|
|
|
|
tc.Set("tuint", uint(1), 0)
|
|
|
|
|
err := tc.Increment("tuint", 2)
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Error("Error incrementing:", err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
x, found := tc.Get("tuint")
|
|
|
|
|
if !found {
|
|
|
|
|
t.Error("tuint was not found")
|
|
|
|
|
}
|
|
|
|
|
if x.(uint) != 3 {
|
|
|
|
|
t.Error("tuint is not 3:", x)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestIncrementUintptr(t *testing.T) {
|
|
|
|
|
tc := New(0, 0)
|
|
|
|
|
tc.Set("tuintptr", uintptr(1), 0)
|
|
|
|
|
err := tc.Increment("tuintptr", 2)
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Error("Error incrementing:", err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
x, found := tc.Get("tuintptr")
|
|
|
|
|
if !found {
|
|
|
|
|
t.Error("tuintptr was not found")
|
|
|
|
|
}
|
|
|
|
|
if x.(uintptr) != 3 {
|
|
|
|
|
t.Error("tuintptr is not 3:", x)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestIncrementUint8(t *testing.T) {
|
|
|
|
|
tc := New(0, 0)
|
|
|
|
|
tc.Set("tuint8", uint8(1), 0)
|
|
|
|
|
err := tc.Increment("tuint8", 2)
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Error("Error incrementing:", err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
x, found := tc.Get("tuint8")
|
|
|
|
|
if !found {
|
|
|
|
|
t.Error("tuint8 was not found")
|
|
|
|
|
}
|
|
|
|
|
if x.(uint8) != 3 {
|
|
|
|
|
t.Error("tuint8 is not 3:", x)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestIncrementUint16(t *testing.T) {
|
|
|
|
|
tc := New(0, 0)
|
|
|
|
|
tc.Set("tuint16", uint16(1), 0)
|
|
|
|
|
err := tc.Increment("tuint16", 2)
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Error("Error incrementing:", err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
x, found := tc.Get("tuint16")
|
|
|
|
|
if !found {
|
|
|
|
|
t.Error("tuint16 was not found")
|
|
|
|
|
}
|
|
|
|
|
if x.(uint16) != 3 {
|
|
|
|
|
t.Error("tuint16 is not 3:", x)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestIncrementUint32(t *testing.T) {
|
|
|
|
|
tc := New(0, 0)
|
|
|
|
|
tc.Set("tuint32", uint32(1), 0)
|
|
|
|
|
err := tc.Increment("tuint32", 2)
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Error("Error incrementing:", err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
x, found := tc.Get("tuint32")
|
|
|
|
|
if !found {
|
|
|
|
|
t.Error("tuint32 was not found")
|
|
|
|
|
}
|
|
|
|
|
if x.(uint32) != 3 {
|
|
|
|
|
t.Error("tuint32 is not 3:", x)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestIncrementUint64(t *testing.T) {
|
|
|
|
|
tc := New(0, 0)
|
|
|
|
|
tc.Set("tuint64", uint64(1), 0)
|
|
|
|
|
err := tc.Increment("tuint64", 2)
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Error("Error incrementing:", err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
x, found := tc.Get("tuint64")
|
|
|
|
|
if !found {
|
|
|
|
|
t.Error("tuint64 was not found")
|
|
|
|
|
}
|
|
|
|
|
if x.(uint64) != 3 {
|
|
|
|
|
t.Error("tuint64 is not 3:", x)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestIncrementInt(t *testing.T) {
|
|
|
|
|
tc := New(0, 0)
|
|
|
|
|
tc.Set("tint", 1, 0)
|
|
|
|
|
err := tc.Increment("tint", 2)
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Error("Error incrementing:", err)
|
|
|
|
|
}
|
|
|
|
|
x, found := tc.Get("tint")
|
|
|
|
|
if !found {
|
|
|
|
|
t.Error("tint was not found")
|
|
|
|
|
}
|
|
|
|
|
if x.(int) != 3 {
|
|
|
|
|
t.Error("tint is not 3:", x)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestIncrementInt8(t *testing.T) {
|
|
|
|
|
tc := New(0, 0)
|
|
|
|
|
tc.Set("tint8", int8(1), 0)
|
|
|
|
|
err := tc.Increment("tint8", 2)
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Error("Error incrementing:", err)
|
|
|
|
|
}
|
|
|
|
|
x, found := tc.Get("tint8")
|
|
|
|
|
if !found {
|
|
|
|
|
t.Error("tint8 was not found")
|
|
|
|
|
}
|
|
|
|
|
if x.(int8) != 3 {
|
|
|
|
|
t.Error("tint8 is not 3:", x)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestIncrementInt16(t *testing.T) {
|
|
|
|
|
tc := New(0, 0)
|
|
|
|
|
tc.Set("tint16", int16(1), 0)
|
|
|
|
|
err := tc.Increment("tint16", 2)
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Error("Error incrementing:", err)
|
|
|
|
|
}
|
|
|
|
|
x, found := tc.Get("tint16")
|
|
|
|
|
if !found {
|
|
|
|
|
t.Error("tint16 was not found")
|
|
|
|
|
}
|
|
|
|
|
if x.(int16) != 3 {
|
|
|
|
|
t.Error("tint16 is not 3:", x)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestIncrementInt32(t *testing.T) {
|
|
|
|
|
tc := New(0, 0)
|
|
|
|
|
tc.Set("tint32", int32(1), 0)
|
|
|
|
|
err := tc.Increment("tint32", 2)
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Error("Error incrementing:", err)
|
|
|
|
|
}
|
|
|
|
|
x, found := tc.Get("tint32")
|
|
|
|
|
if !found {
|
|
|
|
|
t.Error("tint32 was not found")
|
|
|
|
|
}
|
|
|
|
|
if x.(int32) != 3 {
|
|
|
|
|
t.Error("tint32 is not 3:", x)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestIncrementInt64(t *testing.T) {
|
|
|
|
|
tc := New(0, 0)
|
|
|
|
|
tc.Set("tint64", int64(1), 0)
|
|
|
|
|
err := tc.Increment("tint64", 2)
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Error("Error incrementing:", err)
|
|
|
|
|
}
|
|
|
|
|
x, found := tc.Get("tint64")
|
|
|
|
|
if !found {
|
|
|
|
|
t.Error("tint64 was not found")
|
|
|
|
|
}
|
|
|
|
|
if x.(int64) != 3 {
|
|
|
|
|
t.Error("tint64 is not 3:", x)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestIncrementFloat32(t *testing.T) {
|
|
|
|
|
tc := New(0, 0)
|
|
|
|
|
tc.Set("float32", float32(1.5), 0)
|
|
|
|
|
err := tc.Increment("float32", 2)
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Error("Error incrementing:", err)
|
|
|
|
|
}
|
|
|
|
|
x, found := tc.Get("float32")
|
|
|
|
|
if !found {
|
|
|
|
|
t.Error("float32 was not found")
|
|
|
|
|
}
|
|
|
|
|
if x.(float32) != 3.5 {
|
|
|
|
|
t.Error("float32 is not 3.5:", x)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestIncrementFloat64(t *testing.T) {
|
|
|
|
|
tc := New(0, 0)
|
|
|
|
|
tc.Set("float64", float64(1.5), 0)
|
|
|
|
|
err := tc.Increment("float64", 2)
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Error("Error incrementing:", err)
|
|
|
|
|
}
|
|
|
|
|
x, found := tc.Get("float64")
|
|
|
|
|
if !found {
|
|
|
|
|
t.Error("float64 was not found")
|
|
|
|
|
}
|
|
|
|
|
if x.(float64) != 3.5 {
|
|
|
|
|
t.Error("float64 is not 3.5:", x)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestDecrementInt64(t *testing.T) {
|
|
|
|
|
tc := New(0, 0)
|
|
|
|
|
tc.Set("int64", int64(5), 0)
|
|
|
|
|
err := tc.Decrement("int64", 2)
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Error("Error incrementing:", err)
|
|
|
|
|
}
|
|
|
|
|
x, found := tc.Get("int64")
|
|
|
|
|
if !found {
|
|
|
|
|
t.Error("int64 was not found")
|
|
|
|
|
}
|
|
|
|
|
if x.(int64) != 3 {
|
|
|
|
|
t.Error("int64 is not 3:", x)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|