diff --git a/src/Humanizer.Tests.Shared/Bytes/ArithmeticTests.cs b/src/Humanizer.Tests.Shared/Bytes/ArithmeticTests.cs index 6d791c8e5..251af9494 100644 --- a/src/Humanizer.Tests.Shared/Bytes/ArithmeticTests.cs +++ b/src/Humanizer.Tests.Shared/Bytes/ArithmeticTests.cs @@ -99,7 +99,7 @@ public void IncrementOperator() } [Fact] - public void MinusOperator() + public void NegativeOperator() { var size = ByteSize.FromBytes(2); @@ -129,5 +129,16 @@ public void PlusOperator() Assert.Equal(2, result.Bytes); } + + [Fact] + public void MinusOperator() + { + var size1 = ByteSize.FromBytes(2); + var size2 = ByteSize.FromBytes(1); + + var result = size1 - size2; + + Assert.Equal(1, result.Bytes); + } } } diff --git a/src/Humanizer/Bytes/ByteSize.cs b/src/Humanizer/Bytes/ByteSize.cs index b116f95f4..747ce4307 100644 --- a/src/Humanizer/Bytes/ByteSize.cs +++ b/src/Humanizer/Bytes/ByteSize.cs @@ -296,6 +296,11 @@ public ByteSize Subtract(ByteSize bs) return new ByteSize(b1.Bytes + b2.Bytes); } + public static ByteSize operator -(ByteSize b1, ByteSize b2) + { + return new ByteSize(b1.Bytes - b2.Bytes); + } + public static ByteSize operator ++(ByteSize b) { return new ByteSize(b.Bytes + 1);