Skip to content

Commit

Permalink
Add integer extension for Bits so 2.Bits() is valid
Browse files Browse the repository at this point in the history
  • Loading branch information
GeorgeHahn committed Mar 16, 2014
1 parent e71c5ca commit 5485f4c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Humanizer.Tests/ByteSizeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,14 @@ public void HumanizesBytes()
[Fact]
public void Bits()
{
var size = ((long)2).Bits();
var size = (2).Bits();
Assert.Equal(ByteSize.FromBits(2), size);
}

[Fact]
public void HumanizesBits()
{
var humanized = ((long)2).Bits().Humanize();
var humanized = (2).Bits().Humanize();
Assert.Equal("2 b", humanized);
}
[Fact]
Expand Down
10 changes: 10 additions & 0 deletions src/Humanizer/ByteSizeExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@ public static ByteSize Bits(this long val)
return ByteSize.FromBits(val);
}

/// <summary>
/// Use value as a quantity of bits
/// </summary>
/// <param name="val"></param>
/// <returns></returns>
public static ByteSize Bits(this int val)
{
return ByteSize.FromBits(val);
}

/// <summary>
/// Use value as a quantity of bytes
/// </summary>
Expand Down

0 comments on commit 5485f4c

Please sign in to comment.