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 internal
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)
}
}
|