void it_decodes_an_encoded_long() { hashids.DecodeLong("NV").Should().Equal(new[] { 1L }); hashids.DecodeLong("21OjjRK").Should().Equal(new[] { 2147483648L }); hashids.DecodeLong("D54yen6").Should().Equal(new[] { 4294967296L }); hashids.DecodeLong("KVO9yy1oO5j").Should().Equal(new[] { 666555444333222L }); hashids.DecodeLong("4bNP1L26r").Should().Equal(new[] { 12345678901112L }); hashids.DecodeLong("jvNx4BjM5KYjv").Should().Equal(new[] { Int64.MaxValue }); }
void issue_12_should_not_throw_out_of_range_exception() { var hash = new Hashids("zXZVFf2N38uV"); var longs = new List <long>(); var rand = new Random(); var valueBuffer = new byte[8]; var randLong = 0L; for (var i = 0; i < 100000; i++) { rand.NextBytes(valueBuffer); randLong = BitConverter.ToInt64(valueBuffer, 0); longs.Add(Math.Abs(randLong)); } var encoded = hash.EncodeLong(longs); var decoded = hash.DecodeLong(encoded); decoded.Should().Equal(longs.ToArray()); }