Exemplo n.º 1
0
        public static void CompareBytes()
        {
            var bytes1 = new byte[Nonce.MaxSize];
            var bytes2 = new byte[Nonce.MaxSize];

            for (var i = 0; i < bytes1.Length; i++)
            {
                bytes1[i] = 1;
                for (var j = 0; j < bytes2.Length; j++)
                {
                    bytes2[j] = 1;

                    var left  = new Nonce(bytes1, 0);
                    var right = new Nonce(bytes2, 0);

                    var expected = j.CompareTo(i);
                    var actual   = left.CompareTo(right);

                    Assert.Equal(expected, actual);
                    Assert.Equal(expected < 0, left < right);
                    Assert.Equal(expected <= 0, left <= right);
                    Assert.Equal(expected > 0, left > right);
                    Assert.Equal(expected >= 0, left >= right);

                    bytes2[j] = 0;
                }
                bytes1[i] = 0;
            }
        }
Exemplo n.º 2
0
        public static void CompareValue(int first, int second)
        {
            var left  = new Nonce(0, 4) + first;
            var right = new Nonce(0, 4) + second;

            var expected = Math.Sign(first.CompareTo(second));
            var actual   = left.CompareTo(right);

            Assert.Equal(expected, actual);
            Assert.Equal(expected < 0, left < right);
            Assert.Equal(expected <= 0, left <= right);
            Assert.Equal(expected > 0, left > right);
            Assert.Equal(expected >= 0, left >= right);
        }
Exemplo n.º 3
0
        public static void CompareSize(int second)
        {
            const int first = 5;

            var left  = new Nonce(0, first);
            var right = new Nonce(0, second);

            var expected = Math.Sign(first.CompareTo(second));
            var actual   = left.CompareTo(right);

            Assert.Equal(expected, actual);
            Assert.Equal(expected < 0, left < right);
            Assert.Equal(expected <= 0, left <= right);
            Assert.Equal(expected > 0, left > right);
            Assert.Equal(expected >= 0, left >= right);
        }