2022-08-24 02:54:01 +00:00
|
|
|
package erasureencode
|
|
|
|
|
|
|
|
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) {
|
2022-08-25 03:12:12 +00:00
|
|
|
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)
|
|
|
|
}
|
|
|
|
}
|