-
Notifications
You must be signed in to change notification settings - Fork 167
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
140 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package shuffle | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
"go.dedis.ch/kyber/v3" | ||
) | ||
|
||
func TestAssertXY(t *testing.T) { | ||
type tdata struct { | ||
x [][]kyber.Point | ||
y [][]kyber.Point | ||
errStr string | ||
} | ||
|
||
// express possible wrong cases and the expected errors | ||
|
||
table := []tdata{ | ||
{ | ||
x: nil, | ||
y: nil, | ||
errStr: "X is empty", | ||
}, | ||
{ | ||
x: [][]kyber.Point{{}}, | ||
y: [][]kyber.Point{{}}, | ||
errStr: "X is empty", | ||
}, | ||
{ | ||
x: [][]kyber.Point{make([]kyber.Point, 1)}, | ||
y: [][]kyber.Point{{}}, | ||
errStr: "Y is empty", | ||
}, | ||
{ | ||
x: [][]kyber.Point{make([]kyber.Point, 1)}, | ||
y: nil, | ||
errStr: "Y is empty", | ||
}, | ||
{ | ||
x: [][]kyber.Point{make([]kyber.Point, 1), make([]kyber.Point, 2)}, | ||
y: [][]kyber.Point{make([]kyber.Point, 1)}, | ||
errStr: "X and Y have a different size: 2 != 1", | ||
}, | ||
{ | ||
x: [][]kyber.Point{make([]kyber.Point, 1)}, | ||
y: [][]kyber.Point{make([]kyber.Point, 2)}, | ||
errStr: "Y[0] has unexpected size: 1 != 2", | ||
}, | ||
{ | ||
x: [][]kyber.Point{make([]kyber.Point, 1), make([]kyber.Point, 2)}, | ||
y: [][]kyber.Point{make([]kyber.Point, 1), make([]kyber.Point, 1)}, | ||
errStr: "X[1] has unexpected size: 1 != 2", | ||
}, | ||
} | ||
|
||
for _, entry := range table { | ||
err := assertXY(entry.x, entry.y) | ||
require.EqualError(t, err, entry.errStr) | ||
} | ||
|
||
// check valid data | ||
|
||
x := [][]kyber.Point{make([]kyber.Point, 2), make([]kyber.Point, 2)} | ||
y := [][]kyber.Point{make([]kyber.Point, 2), make([]kyber.Point, 2)} | ||
|
||
err := assertXY(x, y) | ||
require.NoError(t, err) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters