14cc967d19
This change includes a leftovers from https://github.com/ethereum/go-ethereum/pull/29307 - using the [new `slices` package](https://go.dev/doc/go1.21#slices) and - using the [new `cmp.Ordered`](https://go.dev/doc/go1.21#cmp) instead of exp `constraints.Ordered`
23 lines
363 B
Go
23 lines
363 B
Go
package metrics
|
|
|
|
import (
|
|
"slices"
|
|
"testing"
|
|
)
|
|
|
|
func TestMetricsSorting(t *testing.T) {
|
|
var namedMetrics = []namedMetric{
|
|
{name: "zzz"},
|
|
{name: "bbb"},
|
|
{name: "fff"},
|
|
{name: "ggg"},
|
|
}
|
|
|
|
slices.SortFunc(namedMetrics, namedMetric.cmp)
|
|
for i, name := range []string{"bbb", "fff", "ggg", "zzz"} {
|
|
if namedMetrics[i].name != name {
|
|
t.Fail()
|
|
}
|
|
}
|
|
}
|