From 9366b51acef2a9acb6d2127f33cfa00fa84b63ee Mon Sep 17 00:00:00 2001 From: Evgeniy Kulikov Date: Mon, 27 Jan 2020 15:02:14 +0300 Subject: [PATCH 1/2] Fix NaN ObjectSize --- object/service.go | 4 ++-- object/utils.go | 2 +- object/utils_test.go | 7 ++++++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/object/service.go b/object/service.go index 84825392..38dbee17 100644 --- a/object/service.go +++ b/object/service.go @@ -39,8 +39,8 @@ type ( ) const ( - // UnitsB starts enum for amount of bytes. - UnitsB int64 = 1 << (10 * iota) + // starts enum for amount of bytes. + _ int64 = 1 << (10 * iota) // UnitsKB defines amount of bytes in one kilobyte. UnitsKB diff --git a/object/utils.go b/object/utils.go index fab7fcc8..7e628f1b 100644 --- a/object/utils.go +++ b/object/utils.go @@ -32,7 +32,7 @@ func (b ByteSize) String() string { case num > UnitsKB: unit = "KB" dec = UnitsKB - case num > UnitsB: + default: dec = 1 } diff --git a/object/utils_test.go b/object/utils_test.go index a3f0162b..d4d7fe2a 100644 --- a/object/utils_test.go +++ b/object/utils_test.go @@ -7,11 +7,16 @@ import ( ) func TestByteSize_String(t *testing.T) { - var cases = []struct { + cases := []struct { name string expect string actual ByteSize }{ + { + name: "0 bytes", + expect: "0", + actual: ByteSize(0), + }, { name: "101 bytes", expect: "101", From 131ec937da119d9b10910426f1653665a00f3d28 Mon Sep 17 00:00:00 2001 From: Evgeniy Kulikov Date: Mon, 27 Jan 2020 15:51:58 +0300 Subject: [PATCH 2/2] Update changelog for v0.2.12 --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 80012c6a..3d09b11c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ # Changelog This is the changelog for NeoFS Proto +## [0.2.12] - 2020-01-27 + +### Fixed +- Bug with ByteSize (0 bytes returns NaN) + ## [0.2.11] - 2020-01-21 ### Added @@ -118,3 +123,4 @@ Initial public release [0.2.9]: https://github.com/nspcc-dev/neofs-proto/compare/v0.2.8...v0.2.9 [0.2.10]: https://github.com/nspcc-dev/neofs-proto/compare/v0.2.9...v0.2.10 [0.2.11]: https://github.com/nspcc-dev/neofs-proto/compare/v0.2.10...v0.2.11 +[0.2.12]: https://github.com/nspcc-dev/neofs-proto/compare/v0.2.11...v0.2.12