public void ByteString_Compare_Test()
        {
            var byteString1 = ByteString.CopyFrom(new byte[] { });
            var byteString2 = ByteString.CopyFrom(new byte[1] {
                02
            });
            var byteString3 = ByteString.CopyFrom(new byte[2] {
                04, 10
            });
            var byteString4 = ByteString.CopyFrom(new byte[3] {
                10, 12, 14
            });
            var byteString5 = ByteString.CopyFrom(new byte[3] {
                00, 12, 14
            });
            var byteString6 = ByteString.CopyFrom(new byte[3] {
                00, 12, 14
            });

            ByteStringHelper.Compare(ByteString.Empty, ByteString.Empty).ShouldBe(0);
            ByteStringHelper.Compare(byteString1, byteString2).ShouldBe(0);
            ByteStringHelper.Compare(byteString2, byteString3).ShouldBe(-1);
            ByteStringHelper.Compare(byteString3, byteString4).ShouldBe(-1);
            ByteStringHelper.Compare(byteString4, byteString5).ShouldBe(1);
            ByteStringHelper.Compare(byteString5, byteString6).ShouldBe(0);
        }
Exemplo n.º 2
0
Arquivo: Hash.cs Projeto: zhxymh/AElf
        private static int CompareHash(Hash hash1, Hash hash2)
        {
            if (hash1 != null)
            {
                return(hash2 == null ? 1 : ByteStringHelper.Compare(hash1.Value, hash2.Value));
            }

            if (hash2 == null)
            {
                return(0);
            }

            return(-1);
        }
Exemplo n.º 3
0
        private static int CompareAddress(Address address1, Address address2)
        {
            if (address1 != null)
            {
                return(address2 == null ? 1 : ByteStringHelper.Compare(address1.Value, address2.Value));
            }

            if (address2 == null)
            {
                return(0);
            }

            return(-1);
        }