github.com/celestiaorg/celestia-node@v0.15.0-beta.1/share/availability/light/sample_test.go (about) 1 package light 2 3 import ( 4 "testing" 5 6 "github.com/stretchr/testify/assert" 7 ) 8 9 func TestSampleSquare(t *testing.T) { 10 tests := []struct { 11 width int 12 samples int 13 }{ 14 {width: 10, samples: 5}, 15 {width: 500, samples: 90}, 16 } 17 18 for _, tt := range tests { 19 ss, err := SampleSquare(tt.width, tt.samples) 20 assert.NoError(t, err) 21 assert.Len(t, ss, tt.samples) 22 // check points are within width 23 for _, s := range ss { 24 assert.Less(t, s.Row, tt.width) 25 assert.Less(t, s.Col, tt.width) 26 } 27 // checks samples are not equal 28 for i, s1 := range ss { 29 for j, s2 := range ss { 30 if i != j { 31 assert.NotEqualValues(t, s1, s2) 32 } 33 } 34 } 35 } 36 }