2013-04-03 20:33:32 +04:00
|
|
|
// Copyright (c) 2013, Prometheus Team
|
2013-01-19 17:48:30 +04:00
|
|
|
// All rights reserved.
|
|
|
|
//
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
2013-04-03 20:33:32 +04:00
|
|
|
package prometheus
|
2013-01-19 17:48:30 +04:00
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
2013-04-03 20:33:32 +04:00
|
|
|
func testLabelsToSignature(t tester) {
|
2013-01-19 17:48:30 +04:00
|
|
|
var scenarios = []struct {
|
|
|
|
in map[string]string
|
2013-06-27 20:46:16 +04:00
|
|
|
out uint64
|
2013-01-19 17:48:30 +04:00
|
|
|
}{
|
|
|
|
{
|
|
|
|
in: map[string]string{},
|
2013-06-27 20:46:16 +04:00
|
|
|
out: 14695981039346656037,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
in: map[string]string{"name": "garland, briggs", "fear": "love is not enough"},
|
|
|
|
out: 15753083015552662396,
|
2013-01-19 17:48:30 +04:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
for i, scenario := range scenarios {
|
2013-04-03 20:33:32 +04:00
|
|
|
actual := labelsToSignature(scenario.in)
|
2013-01-19 17:48:30 +04:00
|
|
|
|
|
|
|
if actual != scenario.out {
|
|
|
|
t.Errorf("%d. expected %s, got %s", i, scenario.out, actual)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestLabelToSignature(t *testing.T) {
|
|
|
|
testLabelsToSignature(t)
|
|
|
|
}
|
|
|
|
|
|
|
|
func BenchmarkLabelToSignature(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
testLabelsToSignature(b)
|
|
|
|
}
|
|
|
|
}
|