2018-02-23 03:56:08 -06:00
|
|
|
package metrics
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
2023-06-19 01:53:15 -05:00
|
|
|
|
|
|
|
"golang.org/x/exp/slices"
|
2018-02-23 03:56:08 -06:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestMetricsSorting(t *testing.T) {
|
2023-06-19 01:53:15 -05:00
|
|
|
var namedMetrics = []namedMetric{
|
2018-02-23 03:56:08 -06:00
|
|
|
{name: "zzz"},
|
|
|
|
{name: "bbb"},
|
|
|
|
{name: "fff"},
|
|
|
|
{name: "ggg"},
|
|
|
|
}
|
|
|
|
|
2023-06-19 01:53:15 -05:00
|
|
|
slices.SortFunc(namedMetrics, namedMetric.less)
|
2018-02-23 03:56:08 -06:00
|
|
|
for i, name := range []string{"bbb", "fff", "ggg", "zzz"} {
|
|
|
|
if namedMetrics[i].name != name {
|
|
|
|
t.Fail()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|