1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
// Copyright 2020 New Relic Corporation. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
package newrelic
import (
"testing"
"time"
)
func dur(d int) time.Duration {
return time.Duration(d)
}
func TestCalculateApdexZone(t *testing.T) {
if z := calculateApdexZone(dur(10), dur(1)); z != apdexSatisfying {
t.Fatal(z)
}
if z := calculateApdexZone(dur(10), dur(10)); z != apdexSatisfying {
t.Fatal(z)
}
if z := calculateApdexZone(dur(10), dur(11)); z != apdexTolerating {
t.Fatal(z)
}
if z := calculateApdexZone(dur(10), dur(40)); z != apdexTolerating {
t.Fatal(z)
}
if z := calculateApdexZone(dur(10), dur(41)); z != apdexFailing {
t.Fatal(z)
}
if z := calculateApdexZone(dur(10), dur(100)); z != apdexFailing {
t.Fatal(z)
}
}
func TestApdexLabel(t *testing.T) {
if out := apdexSatisfying.label(); "S" != out {
t.Fatal(out)
}
if out := apdexTolerating.label(); "T" != out {
t.Fatal(out)
}
if out := apdexFailing.label(); "F" != out {
t.Fatal(out)
}
if out := apdexNone.label(); "" != out {
t.Fatal(out)
}
}
|