2018-02-23 03:56:08 -06:00
|
|
|
package metrics
|
|
|
|
|
|
|
|
import (
|
2024-03-25 01:50:18 -05:00
|
|
|
"slices"
|
2018-02-23 03:56:08 -06:00
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
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-08-11 17:04:12 -05:00
|
|
|
slices.SortFunc(namedMetrics, namedMetric.cmp)
|
2018-02-23 03:56:08 -06:00
|
|
|
for i, name := range []string{"bbb", "fff", "ggg", "zzz"} {
|
|
|
|
if namedMetrics[i].name != name {
|
|
|
|
t.Fail()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|