jsakamoto / ipaddressrange

.NET Class Library for range of IP address, both IPv4 and IPv6.
Mozilla Public License 2.0
370 stars 71 forks source link

Bits static class reverses LE and GE #39

Closed craigb closed 6 years ago

craigb commented 6 years ago

It looks like the LE and GE operations are reversed in the Bits class.

[Theory]
[InlineData("0.0.0.0", "255.255.255.254")]
[InlineData("192.168.10.0", "192.168.10.254")]
[InlineData("192.168.10.0", "192.168.11.254")]
[InlineData("192.168.10.0", "192.168.11.255")]
public void Bits_comparisons_are_backwards(string start, string end)
{
    var startBytes = System.Net.IPAddress.Parse(start).GetAddressBytes();
    var endBytes = System.Net.IPAddress.Parse(end).GetAddressBytes();

    Assert.False(NetTools.Bits.LE(startBytes, endBytes));
    Assert.True(NetTools.Bits.GE(startBytes, endBytes));
}
jsakamoto commented 6 years ago

:O

jsakamoto commented 6 years ago

Thank you for your reporting!

Nobody could not report or recognize this problem for a long years...!

Fortunately, @Menur already fixed this problem and sent a pull request.

I should consider any programs which depend on this bug behavior, so I'll fixed this issue with keeping backward compatibility.

(In my plan, I'll add new fixed class like Bits2)