Exemplo n.º 1
0
        public void UInt256FromHexString(string hexString, string expectedResult)
        {
            var num       = UInt256.FromHexString(hexString);
            var numString = num.ToString();

            Assert.Equal(expectedResult, numString);

            // test loose casting
            var num2       = (UInt256)hexString;
            var numString2 = num2.ToString();

            Assert.Equal(expectedResult, numString2);
        }
Exemplo n.º 2
0
        public void UInt256HexConversions()
        {
            UInt256 num       = 123456789;
            var     hex       = num.ToHexString();
            UInt256 roundTrip = UInt256.FromHexString(hex);

            Assert.Equal(num, roundTrip);

            num       = 0;
            hex       = num.ToHexString();
            roundTrip = UInt256.FromHexString(hex);
            Assert.Equal(num, roundTrip);

            num       = UInt256.MaxValue;
            hex       = num.ToHexString();
            roundTrip = UInt256.FromHexString(hex);
            Assert.Equal(num, roundTrip);

            num       = 486854645767;
            hex       = num.ToHexString(hexPrefix: false);
            roundTrip = UInt256.FromHexString(hex);
            Assert.Equal(num, roundTrip);
        }