| 1 | package bankinfo |
| 2 | |
| 3 | import "testing" |
| 4 | |
| 5 | func TestSortableBicInfosSortInterface(t *testing.T) { |
| 6 | sorted := sortableBicInfos{ |
| 7 | BicInfo{BankID: "30000000"}, |
| 8 | BicInfo{BankID: "10000000"}, |
| 9 | BicInfo{BankID: "20000000"}, |
| 10 | } |
| 11 | |
| 12 | length := sorted.Len() |
| 13 | |
| 14 | if len(sorted) != length { |
| 15 | t.Logf("Expected length to equal %d, got %d\n", len(sorted), length) |
| 16 | t.Fail() |
| 17 | } |
| 18 | |
| 19 | less := sorted.Less(0, 1) |
| 20 | |
| 21 | if less { |
| 22 | t.Logf("Expected first entry not to be less than second, but was\n") |
| 23 | t.Fail() |
| 24 | } |
| 25 | |
| 26 | sorted.Swap(0, 1) |
| 27 | |
| 28 | if sorted[0].BankID != "10000000" { |
| 29 | t.Logf("Expected first entry to have BankId '10000000', but was %q\n", sorted[0].BankID) |
| 30 | t.Fail() |
| 31 | } |
| 32 | |
| 33 | if sorted[1].BankID != "30000000" { |
| 34 | t.Logf("Expected first entry to have BankId '30000000', but was %q\n", sorted[1].BankID) |
| 35 | t.Fail() |
| 36 | } |
| 37 | } |