mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2024-11-23 12:16:38 +00:00
5004e0a9da
* fix error check of prune to allow missing files * update go-store library, add test for pruning item with db entry but no file Signed-off-by: kim <grufwub@gmail.com> * remove now-unneccessary error check Signed-off-by: kim <grufwub@gmail.com> Co-authored-by: kim <grufwub@gmail.com>
61 lines
1.5 KiB
Smarty
61 lines
1.5 KiB
Smarty
package atomics_test
|
|
|
|
import (
|
|
"atomic"
|
|
"unsafe"
|
|
"testing"
|
|
|
|
"codeberg.org/gruf/go-atomics"
|
|
)
|
|
|
|
func Test{{ .Name }}StoreLoad(t *testing.T) {
|
|
for _, test := range {{ .Name }}Tests {
|
|
val := atomics.New{{ .Name }}()
|
|
|
|
val.Store(test.V1)
|
|
|
|
if !({{ call .Compare "val.Load()" "test.V1" }}) {
|
|
t.Fatalf("failed testing .Store and .Load: expect=%v actual=%v", val.Load(), test.V1)
|
|
}
|
|
|
|
val.Store(test.V2)
|
|
|
|
if !({{ call .Compare "val.Load()" "test.V2" }}) {
|
|
t.Fatalf("failed testing .Store and .Load: expect=%v actual=%v", val.Load(), test.V2)
|
|
}
|
|
}
|
|
}
|
|
|
|
func Test{{ .Name }}CAS(t *testing.T) {
|
|
for _, test := range {{ .Name }}Tests {
|
|
val := atomics.New{{ .Name }}()
|
|
|
|
val.Store(test.V1)
|
|
|
|
if val.CAS(test.V2, test.V1) {
|
|
t.Fatalf("failed testing negative .CAS: test=%+v state=%v", test, val.Load())
|
|
}
|
|
|
|
if !val.CAS(test.V1, test.V2) {
|
|
t.Fatalf("failed testing positive .CAS: test=%+v state=%v", test, val.Load())
|
|
}
|
|
}
|
|
}
|
|
|
|
func Test{{ .Name }}Swap(t *testing.T) {
|
|
for _, test := range {{ .Name }}Tests {
|
|
val := atomics.New{{ .Name }}()
|
|
|
|
val.Store(test.V1)
|
|
|
|
if !({{ call .Compare "val.Swap(test.V2)" "test.V1" }}) {
|
|
t.Fatal("failed testing .Swap")
|
|
}
|
|
|
|
if !({{ call .Compare "val.Swap(test.V1)" "test.V2" }}) {
|
|
t.Fatal("failed testing .Swap")
|
|
}
|
|
}
|
|
}
|
|
|