Skip to content

Commit d199026

Browse files
committed
FriendlyByteConverterTest.cs
1 parent 5ddda6f commit d199026

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using Coder.Desktop.App.Converters;
2+
3+
namespace Coder.Desktop.Tests.App.Converters;
4+
5+
[TestFixture]
6+
public class FriendlyByteConverterTest
7+
{
8+
[Test]
9+
public void EndToEnd()
10+
{
11+
var cases = new List<(object, string)>
12+
{
13+
(0, "0 B"),
14+
((uint)0, "0 B"),
15+
((long)0, "0 B"),
16+
((ulong)0, "0 B"),
17+
18+
(1, "1 B"),
19+
(1024, "1 KB"),
20+
((ulong)(1.1 * 1024), "1.1 KB"),
21+
(1024 * 1024, "1 MB"),
22+
(1024 * 1024 * 1024, "1 GB"),
23+
((ulong)1024 * 1024 * 1024 * 1024, "1 TB"),
24+
((ulong)1024 * 1024 * 1024 * 1024 * 1024, "1 PB"),
25+
((ulong)1024 * 1024 * 1024 * 1024 * 1024 * 1024, "1 EB"),
26+
(ulong.MaxValue, "16 EB"),
27+
};
28+
29+
var converter = new FriendlyByteConverter();
30+
foreach (var (input, expected) in cases)
31+
{
32+
var actual = converter.Convert(input, typeof(string), null, null);
33+
Assert.That(actual, Is.EqualTo(expected), $"case ({input.GetType()}){input}");
34+
}
35+
}
36+
}

0 commit comments

Comments
 (0)