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