Skip to content

Commit 6bb757a

Browse files
author
AndrewMorgan1
committed
Added negative round trip test to HumanBytesExtensionsTests
1 parent 9790606 commit 6bb757a

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

tests/ByteFlow.Tests/HumanBytesExtensionsTests.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,5 +142,18 @@ public void RoundTrip_BytesToHumanAndBack_ShouldBeConsistent(long original)
142142
double tolerance = original * 0.01; // 1% margin
143143
Assert.InRange(parsed, original - tolerance, original + tolerance);
144144
}
145+
146+
[Theory]
147+
[InlineData("NotBytes")]
148+
[InlineData("123 QZ")] // invalid suffix
149+
[InlineData("1.2.3 GB")] // malformed number
150+
public void RoundTrip_InvalidStrings_ShouldFailGracefully(string input)
151+
{
152+
153+
bool success = input.TryParseHumanBytes(out long result);
154+
155+
Assert.False(success);
156+
Assert.Equal(0, result);
157+
}
145158
}
146159
}

0 commit comments

Comments
 (0)