Exemplo n.º 1
0
 public void ArrayEx_Compare()
 {
     Assert.AreEqual(-1, ArrayEx.Compare(new byte[] { 1 }, new byte[] { 1, 2 }, 2));
     Assert.AreEqual(1, ArrayEx.Compare(new byte[] { 1, 2 }, new byte[] { 1 }, 2));
     Assert.AreEqual(1, ArrayEx.Compare(new byte[] { 1, 2 }, new byte[] { 1, 1 }, 2));
     Assert.AreEqual(0, ArrayEx.Compare(new byte[] { 1, 2 }, new byte[] { 1, 2 }, 2));
     Assert.AreEqual(-1, ArrayEx.Compare(new byte[] { 1, 2 }, new byte[] { 1, 3 }, 2));
 }
Exemplo n.º 2
0
 public void ArrayEx_Compare3()
 {
     Assert.AreEqual(-1, ArrayEx.Compare(new byte[] { (byte)'1' }, 0, "12", 2));
     Assert.AreEqual(1, ArrayEx.Compare(new byte[] { (byte)'1', (byte)'2' }, 0, "1", 2));
     Assert.AreEqual(1, ArrayEx.Compare(new byte[] { (byte)'1', (byte)'2' }, 0, "11", 2));
     Assert.AreEqual(0, ArrayEx.Compare(new byte[] { (byte)'1', (byte)'2' }, 0, "12", 2));
     Assert.AreEqual(-1, ArrayEx.Compare(new byte[] { (byte)'1', (byte)'2' }, 0, "13", 2));
 }
Exemplo n.º 3
0
        public void ConvertEx_PutVariant4()
        {
            var b = new byte[9];

            // 1
            Assert.AreEqual(1, ConvertEx.PutVariant4(b, 1)); Assert.AreEqual(0, ArrayEx.Compare(b, new byte[] { 1 }, 1));
            Assert.AreEqual(1, ConvertEx.PutVariant4(b, 0U, 1)); Assert.AreEqual(0, ArrayEx.Compare(b, new byte[] { 1 }, 1));
            // 0x7F
            Assert.AreEqual(1, ConvertEx.PutVariant4(b, 127)); Assert.AreEqual(0, ArrayEx.Compare(b, new byte[] { 0x7F }, 1));
            Assert.AreEqual(1, ConvertEx.PutVariant4(b, 0U, 127)); Assert.AreEqual(0, ArrayEx.Compare(b, new byte[] { 0x7F }, 1));
            // 0x80
            Assert.AreEqual(2, ConvertEx.PutVariant4(b, 128)); Assert.AreEqual(0, ArrayEx.Compare(b, new byte[] { 0x81, 0x0 }, 1));
            Assert.AreEqual(2, ConvertEx.PutVariant4(b, 0U, 128)); Assert.AreEqual(0, ArrayEx.Compare(b, new byte[] { 0x81, 0x0 }, 1));
        }
Exemplo n.º 4
0
        public void ConvertEx_Put2()
        {
            var b = new byte[2];

            ConvertEx.Put2(b, 1); Assert.AreEqual(0, ArrayEx.Compare(b, new byte[] { 0, 0, 0, 1 }, 1));
            ConvertEx.Put2(b, 1U); Assert.AreEqual(0, ArrayEx.Compare(b, new byte[] { 0, 0, 0, 1 }, 1));
            ConvertEx.Put2(b, 0, 1); Assert.AreEqual(0, ArrayEx.Compare(b, new byte[] { 0, 0, 0, 1 }, 1));
            ConvertEx.Put2(b, 0, 1U); Assert.AreEqual(0, ArrayEx.Compare(b, new byte[] { 0, 0, 0, 1 }, 1));
            ConvertEx.Put2(b, 0U, 1); Assert.AreEqual(0, ArrayEx.Compare(b, new byte[] { 0, 0, 0, 1 }, 1));
            ConvertEx.Put2(b, 0U, 1U); Assert.AreEqual(0, ArrayEx.Compare(b, new byte[] { 0, 0, 0, 1 }, 1));
            ConvertEx.Put2(b, 0, (short)1); Assert.AreEqual(0, ArrayEx.Compare(b, new byte[] { 0, 0, 0, 1 }, 1));
            ConvertEx.Put2(b, 0, (ushort)1U); Assert.AreEqual(0, ArrayEx.Compare(b, new byte[] { 0, 0, 0, 1 }, 1));
            ConvertEx.Put2(b, 0U, (short)1); Assert.AreEqual(0, ArrayEx.Compare(b, new byte[] { 0, 0, 0, 1 }, 1));
            ConvertEx.Put2(b, 0U, (ushort)1U); Assert.AreEqual(0, ArrayEx.Compare(b, new byte[] { 0, 0, 0, 1 }, 1));
        }
Exemplo n.º 5
0
        public void ConvertEx_Put4()
        {
            var b = new byte[9];

            ConvertEx.Put4(b, 1); Assert.AreEqual(0, ArrayEx.Compare(b, new byte[] { 0, 0, 0, 1 }, 1));
            ConvertEx.Put4(b, 1U); Assert.AreEqual(0, ArrayEx.Compare(b, new byte[] { 0, 0, 0, 1 }, 1));
            ConvertEx.Put4(b, 0, 1); Assert.AreEqual(0, ArrayEx.Compare(b, new byte[] { 0, 0, 0, 1 }, 1));
            ConvertEx.Put4(b, 0, 1U); Assert.AreEqual(0, ArrayEx.Compare(b, new byte[] { 0, 0, 0, 1 }, 1));
            ConvertEx.Put4(b, 0U, 1); Assert.AreEqual(0, ArrayEx.Compare(b, new byte[] { 0, 0, 0, 1 }, 1));
            ConvertEx.Put4(b, 0U, 1U); Assert.AreEqual(0, ArrayEx.Compare(b, new byte[] { 0, 0, 0, 1 }, 1));
            ConvertEx.Put4L(b, 1L); Assert.AreEqual(0, ArrayEx.Compare(b, new byte[] { 0, 0, 0, 1 }, 1));
            ConvertEx.Put4L(b, 1UL); Assert.AreEqual(0, ArrayEx.Compare(b, new byte[] { 0, 0, 0, 1 }, 1));
            ConvertEx.Put4L(b, 0U, 1L); Assert.AreEqual(0, ArrayEx.Compare(b, new byte[] { 0, 0, 0, 1 }, 1));
            ConvertEx.Put4L(b, 0U, 1UL); Assert.AreEqual(0, ArrayEx.Compare(b, new byte[] { 0, 0, 0, 1 }, 1));
        }