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