github.com/sberex/go-sberex@v1.8.2-0.20181113200658-ed96ac38f7d7/common/size_test.go (about) 1 // This file is part of the go-sberex library. The go-sberex library is 2 // free software: you can redistribute it and/or modify it under the terms 3 // of the GNU Lesser General Public License as published by the Free 4 // Software Foundation, either version 3 of the License, or (at your option) 5 // any later version. 6 // 7 // The go-sberex library is distributed in the hope that it will be useful, 8 // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 10 // General Public License <http://www.gnu.org/licenses/> for more details. 11 12 package common 13 14 import ( 15 "testing" 16 ) 17 18 func TestStorageSizeString(t *testing.T) { 19 tests := []struct { 20 size StorageSize 21 str string 22 }{ 23 {2381273, "2.38 mB"}, 24 {2192, "2.19 kB"}, 25 {12, "12.00 B"}, 26 } 27 28 for _, test := range tests { 29 if test.size.String() != test.str { 30 t.Errorf("%f: got %q, want %q", float64(test.size), test.size.String(), test.str) 31 } 32 } 33 }