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