Skip to content

Commit 35946dc

Browse files
author
AndrewMorgan1
committed
Added missing test case scenarios for TryParseHumanBytes
1 parent 1f2deba commit 35946dc

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

tests/ByteFlow.Tests/HumanBytesExtensionsTests.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,24 @@ public void ToBytes_InputWithoutSuffix_ShouldThrow()
144144

145145
// --- TryParseHumanBytes ---
146146

147+
[Fact]
148+
public void TryParseHumanBytes_DefaultOverload_ShouldReturnTrue()
149+
{
150+
bool success = "1 KiB".TryParseHumanBytes(out long result);
151+
152+
Assert.True(success);
153+
Assert.Equal(1024, result); // uses default IEC
154+
}
155+
156+
[Fact]
157+
public void TryParseHumanBytes_DefaultOverload_ShouldReturnFalseOnInvalid()
158+
{
159+
bool success = "invalid".TryParseHumanBytes(out long result);
160+
161+
Assert.False(success);
162+
Assert.Equal(0, result);
163+
}
164+
147165
[Theory]
148166
[InlineData("1 MB", 1000000, UnitStandard.SI)]
149167
[InlineData("1 MiB", 1048576, UnitStandard.IEC)]

0 commit comments

Comments
 (0)