mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2024-11-22 09:15:50 +03: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>
98 lines
No EOL
2.2 KiB
Smarty
98 lines
No EOL
2.2 KiB
Smarty
package bitutil_test
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
|
|
"codeberg.org/gruf/go-bytes"
|
|
)
|
|
|
|
{{ range $idx, $size := . }}
|
|
|
|
func TestFlags{{ $size.Size }}Get(t *testing.T) {
|
|
var mask, flags bitutil.Flags{{ $size.Size }}
|
|
|
|
{{ range $idx := $size.Bits }}
|
|
|
|
mask = bitutil.Flags{{ $size.Size }}(1) << {{ $idx }}
|
|
|
|
flags = 0
|
|
|
|
flags |= mask
|
|
if !flags.Get({{ $idx }}) {
|
|
t.Error("failed .Get() set Flags{{ $size.Size }} bit at index {{ $idx }}")
|
|
}
|
|
|
|
flags = ^bitutil.Flags{{ $size.Size }}(0)
|
|
|
|
flags &= ^mask
|
|
if flags.Get({{ $idx }}) {
|
|
t.Error("failed .Get() unset Flags{{ $size.Size }} bit at index {{ $idx }}")
|
|
}
|
|
|
|
flags = 0
|
|
|
|
flags |= mask
|
|
if !flags.Get{{ $idx }}() {
|
|
t.Error("failed .Get{{ $idx }}() set Flags{{ $size.Size }} bit at index {{ $idx }}")
|
|
}
|
|
|
|
flags = ^bitutil.Flags{{ $size.Size }}(0)
|
|
|
|
flags &= ^mask
|
|
if flags.Get{{ $idx }}() {
|
|
t.Error("failed .Get{{ $idx }}() unset Flags{{ $size.Size }} bit at index {{ $idx }}")
|
|
}
|
|
|
|
{{ end }}
|
|
}
|
|
|
|
func TestFlags{{ $size.Size }}Set(t *testing.T) {
|
|
var mask, flags bitutil.Flags{{ $size.Size }}
|
|
|
|
{{ range $idx := $size.Bits }}
|
|
|
|
mask = bitutil.Flags{{ $size.Size }}(1) << {{ $idx }}
|
|
|
|
flags = 0
|
|
|
|
flags = flags.Set({{ $idx }})
|
|
if flags & mask == 0 {
|
|
t.Error("failed .Set() Flags{{ $size.Size }} bit at index {{ $idx }}")
|
|
}
|
|
|
|
flags = 0
|
|
|
|
flags = flags.Set{{ $idx }}()
|
|
if flags & mask == 0 {
|
|
t.Error("failed .Set{{ $idx }}() Flags{{ $size.Size }} bit at index {{ $idx }}")
|
|
}
|
|
|
|
{{ end }}
|
|
}
|
|
|
|
func TestFlags{{ $size.Size }}Unset(t *testing.T) {
|
|
var mask, flags bitutil.Flags{{ $size.Size }}
|
|
|
|
{{ range $idx := $size.Bits }}
|
|
|
|
mask = bitutil.Flags{{ $size.Size }}(1) << {{ $idx }}
|
|
|
|
flags = ^bitutil.Flags{{ $size.Size }}(0)
|
|
|
|
flags = flags.Unset({{ $idx }})
|
|
if flags & mask != 0 {
|
|
t.Error("failed .Unset() Flags{{ $size.Size }} bit at index {{ $idx }}")
|
|
}
|
|
|
|
flags = ^bitutil.Flags{{ $size.Size }}(0)
|
|
|
|
flags = flags.Unset{{ $idx }}()
|
|
if flags & mask != 0 {
|
|
t.Error("failed .Unset{{ $idx }}() Flags{{ $size.Size }} bit at index {{ $idx }}")
|
|
}
|
|
|
|
{{ end }}
|
|
}
|
|
|
|
{{ end }} |