1
0
Fork 0
mirror of https://github.com/Luzifer/ansible-role-version.git synced 2024-10-19 05:14:22 +00:00
ansible-role-version/vendor/github.com/emirpasic/gods/containers/containers_test.go
Knut Ahlers 209b813c5b
Update dependencies
Signed-off-by: Knut Ahlers <knut@ahlers.me>
2018-03-19 18:16:10 +01:00

55 lines
1.3 KiB
Go

// Copyright (c) 2015, Emir Pasic. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// All data structures must implement the container structure
package containers
import (
"github.com/emirpasic/gods/utils"
"testing"
)
// For testing purposes
type ContainerTest struct {
values []interface{}
}
func (container ContainerTest) Empty() bool {
return len(container.values) == 0
}
func (container ContainerTest) Size() int {
return len(container.values)
}
func (container ContainerTest) Clear() {
container.values = []interface{}{}
}
func (container ContainerTest) Values() []interface{} {
return container.values
}
func TestGetSortedValuesInts(t *testing.T) {
container := ContainerTest{}
container.values = []interface{}{5, 1, 3, 2, 4}
values := GetSortedValues(container, utils.IntComparator)
for i := 1; i < container.Size(); i++ {
if values[i-1].(int) > values[i].(int) {
t.Errorf("Not sorted!")
}
}
}
func TestGetSortedValuesStrings(t *testing.T) {
container := ContainerTest{}
container.values = []interface{}{"g", "a", "d", "e", "f", "c", "b"}
values := GetSortedValues(container, utils.StringComparator)
for i := 1; i < container.Size(); i++ {
if values[i-1].(string) > values[i].(string) {
t.Errorf("Not sorted!")
}
}
}