We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 14f9307 commit 9790606Copy full SHA for 9790606
1 file changed
tests/ByteFlow.Tests/HumanBytesExtensionsTests.cs
@@ -126,5 +126,21 @@ public void ToBytes_ShouldHandleVeryLargePetabytes()
126
double expected = 8192 * Math.Pow(1024, 5);
127
Assert.Equal((long)expected, result);
128
}
129
+
130
+ [Theory]
131
+ [InlineData(1)]
132
+ [InlineData(1024)] // 1 KB
133
+ [InlineData(1048576)] // 1 MB
134
+ [InlineData(1073741824)] // 1 GB
135
+ [InlineData(1099511627776)] // 1 TB
136
+ public void RoundTrip_BytesToHumanAndBack_ShouldBeConsistent(long original)
137
+ {
138
+ string human = original.ToHumanBytes();
139
+ long parsed = human.ToBytes();
140
141
+ // Allow slight tolerance because ToHumanBytes() rounds
142
+ double tolerance = original * 0.01; // 1% margin
143
+ Assert.InRange(parsed, original - tolerance, original + tolerance);
144
+ }
145
146
0 commit comments