github.com/lulzWill/go-agent@v2.1.2+incompatible/internal/apdex_test.go (about)

     1  package internal
     2  
     3  import (
     4  	"testing"
     5  	"time"
     6  )
     7  
     8  func dur(d int) time.Duration {
     9  	return time.Duration(d)
    10  }
    11  
    12  func TestCalculateApdexZone(t *testing.T) {
    13  	if z := CalculateApdexZone(dur(10), dur(1)); z != ApdexSatisfying {
    14  		t.Fatal(z)
    15  	}
    16  	if z := CalculateApdexZone(dur(10), dur(10)); z != ApdexSatisfying {
    17  		t.Fatal(z)
    18  	}
    19  	if z := CalculateApdexZone(dur(10), dur(11)); z != ApdexTolerating {
    20  		t.Fatal(z)
    21  	}
    22  	if z := CalculateApdexZone(dur(10), dur(40)); z != ApdexTolerating {
    23  		t.Fatal(z)
    24  	}
    25  	if z := CalculateApdexZone(dur(10), dur(41)); z != ApdexFailing {
    26  		t.Fatal(z)
    27  	}
    28  	if z := CalculateApdexZone(dur(10), dur(100)); z != ApdexFailing {
    29  		t.Fatal(z)
    30  	}
    31  }
    32  
    33  func TestApdexLabel(t *testing.T) {
    34  	if out := ApdexSatisfying.label(); "S" != out {
    35  		t.Fatal(out)
    36  	}
    37  	if out := ApdexTolerating.label(); "T" != out {
    38  		t.Fatal(out)
    39  	}
    40  	if out := ApdexFailing.label(); "F" != out {
    41  		t.Fatal(out)
    42  	}
    43  	if out := ApdexNone.label(); "" != out {
    44  		t.Fatal(out)
    45  	}
    46  }