file-store/pkg/util/main_test.go

38 lines
879 B
Go
Raw Normal View History

package util
2022-08-24 02:54:01 +00:00
import (
"testing"
)
// example uses a tiny shard size for testing
// ex: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, a, b, c, d, e, f, g] ShardSize(2) RS(3,2)
// c0: [01, 67, cd] [s0, s3, s6]
// c1: [23, 89, ef] [s1, s4, s7]
// c2: [45, ab, g0] [s2, s5, s8]
// read(7, 7)
// desired plan 0,3,1; 1,2,2; 2,2,2; 0,4,2 -> 7; 89; ab; cd
func TestMin(t *testing.T) {
expected := int64(61)
2022-08-24 02:54:01 +00:00
actual := min(91, 111111, 9102, 61)
if actual != expected {
t.Fatalf(`Expected output to be %d, got %d`, actual, expected)
}
actual = min(61, 39421)
if actual != expected {
t.Fatalf(`Expected output to be %d, got %d`, actual, expected)
}
actual = min(61)
if actual != expected {
t.Fatalf(`Expected output to be %d, got %d`, actual, expected)
}
actual = min(1923042, 61, 122)
if actual != expected {
t.Fatalf(`Expected output to be %d, got %d`, actual, expected)
}
}