github.com/avenga/couper@v1.12.2/logging/helper_internal_test.go (about)

     1  package logging
     2  
     3  import (
     4  	"testing"
     5  	"time"
     6  )
     7  
     8  func TestHelper_roundMS(t *testing.T) {
     9  	type testCase struct {
    10  		dur time.Duration
    11  		exp float64
    12  	}
    13  
    14  	for _, tc := range []testCase{
    15  		{1234567 * time.Nanosecond, 1.2350},
    16  		{123456 * time.Microsecond, 123.456},
    17  		{123456 * time.Microsecond, 123.456000},
    18  		{123 * time.Millisecond, 123.0},
    19  	} {
    20  		if got := RoundMS(tc.dur); got != tc.exp {
    21  			t.Errorf("expected '%#v', got '%#v'", tc.exp, got)
    22  		}
    23  	}
    24  }