github.com/neatlab/neatio@v1.7.3-0.20220425043230-d903e92fcc75/utilities/common/size_test.go (about)

     1  package common
     2  
     3  import (
     4  	"testing"
     5  )
     6  
     7  func TestStorageSizeString(t *testing.T) {
     8  	tests := []struct {
     9  		size StorageSize
    10  		str  string
    11  	}{
    12  		{2381273, "2.38 mB"},
    13  		{2192, "2.19 kB"},
    14  		{12, "12.00 B"},
    15  	}
    16  
    17  	for _, test := range tests {
    18  		if test.size.String() != test.str {
    19  			t.Errorf("%f: got %q, want %q", float64(test.size), test.size.String(), test.str)
    20  		}
    21  	}
    22  }