mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-19 16:46:55 +00:00
38 lines
508 B
Go
38 lines
508 B
Go
package safe
|
|
|
|
import "testing"
|
|
|
|
func TestValue(t *testing.T) {
|
|
v := NewValue("foo")
|
|
|
|
v.Load(func(data string) {
|
|
if data != "foo" {
|
|
t.Error("expected foo")
|
|
}
|
|
})
|
|
|
|
v.Save("bar")
|
|
|
|
v.Load(func(data string) {
|
|
if data != "bar" {
|
|
t.Error("expected bar")
|
|
}
|
|
})
|
|
|
|
v.Mod(func(data *string) {
|
|
*data = "baz"
|
|
})
|
|
|
|
v.Load(func(data string) {
|
|
if data != "baz" {
|
|
t.Error("expected baz")
|
|
}
|
|
})
|
|
|
|
if LoadRet(v, func(data string) string {
|
|
return data
|
|
}) != "baz" {
|
|
t.Error("expected baz")
|
|
}
|
|
}
|