Skip to content

Commit

Permalink
test(schema): add test for decData
Browse files Browse the repository at this point in the history
  • Loading branch information
0xankit committed Dec 5, 2022
1 parent b990ef4 commit 02a1abc
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions schema/data/base/decData_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ func Test_decDataFromInterface(t *testing.T) {
wantErr assert.ErrorAssertionFunc
}{
{"+ve with nil", args{decData{}}, decData{}, assert.NoError},
{"+ve with nil", args{decData{types.Dec{}}}, decData{}, assert.NoError},
{"+ve with zero dec", args{decData{types.ZeroDec()}}, decData{types.ZeroDec()}, assert.NoError},
{"+ve", args{decData{types.NewDec(100)}}, decData{types.NewDec(100)}, assert.NoError},
{"+ve with -ve Dec", args{decData{types.NewDec(-100)}}, decData{types.NewDec(-100)}, assert.NoError},
Expand Down Expand Up @@ -92,6 +93,9 @@ func Test_decData_Bytes(t *testing.T) {
}

func Test_decData_Compare(t *testing.T) {
require.Panics(t, func() {
decData{}.Compare(nil)
})
type fields struct {
Value types.Dec
}
Expand All @@ -105,6 +109,7 @@ func Test_decData_Compare(t *testing.T) {
want int
}{
{"+ve with nil", fields{}, args{decData{}}, 0},
{"+ve with nil", fields{types.Dec{}}, args{decData{types.Dec{}}}, 0},
{"+ve with zero dec", fields{types.ZeroDec()}, args{decData{types.ZeroDec()}}, 0},
{"+ve", fields{types.NewDec(100)}, args{decData{types.NewDec(100)}}, 0},
{"-ve", fields{types.NewDec(-100)}, args{decData{types.NewDec(100)}}, -1},
Expand All @@ -130,8 +135,7 @@ func Test_decData_GenerateHashID(t *testing.T) {
want ids.HashID
wantPanic bool
}{
// TODO: Update Unit tests after fix
{"panic case with nil", fields{types.Dec{}}, baseIDs.GenerateHashID([]byte{}), true}, // TODO: Check if Panic case for nil Dec is expected behaviour
{"panic case with nil", fields{types.Dec{}}, baseIDs.GenerateHashID(), false},
{"+ve with zero dec", fields{types.ZeroDec()}, baseIDs.GenerateHashID(), false},
{"+ve", fields{types.NewDec(100)}, baseIDs.GenerateHashID(decData{types.NewDec(100)}.Bytes()), false},
{"+ve with -ve Dec", fields{types.NewDec(-100)}, baseIDs.GenerateHashID(decData{types.NewDec(-100)}.Bytes()), false},
Expand Down

0 comments on commit 02a1abc

Please sign in to comment.