Skip to content

Commit

Permalink
Adding unit tests for Order ID sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
mtlynch committed Oct 2, 2016
1 parent 1704664 commit b523df5
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions types/orders_test.go
@@ -0,0 +1,29 @@
package types

import (
"reflect"
"sort"
"testing"
)

func TestSortOrderIDs(t *testing.T) {
var tests = []struct {
unsorted OrderIDs
want OrderIDs
}{
{
unsorted: OrderIDs{"id-a", "id-b", "id-c"},
want: OrderIDs{"id-a", "id-b", "id-c"},
},
{
unsorted: OrderIDs{"id-c", "id-b", "id-a"},
want: OrderIDs{"id-a", "id-b", "id-c"},
},
}
for _, tt := range tests {
sort.Sort(tt.unsorted)
if !reflect.DeepEqual(tt.unsorted, tt.want) {
t.Errorf("sorting order IDs failed, got: %v, want: %v", tt.unsorted, tt.want)
}
}
}

0 comments on commit b523df5

Please sign in to comment.