Exemplo n.º 1
0
        public void GetBytes_Returns_RightmostBytes()
        {
            /* The full number is 00000101 00001100 01000010 00100011‬
             * but we are only getting bytes from 100 01000010 00100011
             * That should be 4, 66, 35; reversed
             */
            BinaryNumber binary = 84689443;

            Assert.AreEqual(new byte[] { 35, 66, 4 }, binary.GetBytes(19));
        }
Exemplo n.º 2
0
        public void GetBytes_Throws_With_Negative()
        {
            BinaryNumber binary = 84689443;

            Assert.That(() => binary.GetBytes(-1), Throws.TypeOf <System.ArgumentOutOfRangeException>());
        }
Exemplo n.º 3
0
        public void GetBytes_With_0_Returns_Empty()
        {
            BinaryNumber binary = 84689443;

            Assert.IsEmpty(binary.GetBytes(0));
        }
Exemplo n.º 4
0
        public void GetBytes_Returns_1ByteForEvery8Bits([Values(1, 9, 25, 57)] int significantBits, [Values(1, 2, 4, 8)] int numberOfBytes)
        {
            BinaryNumber binary = ulong.MaxValue;

            Assert.AreEqual(numberOfBytes, binary.GetBytes(significantBits).Length);
        }
Exemplo n.º 5
0
        public void GetBytes_Throws_With_GreaterThan64()
        {
            BinaryNumber binary = 84689443;

            Assert.That(() => binary.GetBytes(65), Throws.TypeOf <System.ArgumentOutOfRangeException>());
        }