예제 #1
0
 public void ToInt64_RepresentationLengthDiffThanTotalBitsSum_Exception()
 {
     Assert.Catch <ArgumentException>(delegate
     {
         BinaryStringRepresentation.ToInt64("000100001000000011", new int[] { 4, 6, 9 });
     });
 }
예제 #2
0
        public void ToInt64_RepresentationAndTotalBitsArray_Int64s()
        {
            var actual = BinaryStringRepresentation.ToInt64("000100001000000011", new int[] { 4, 6, 8 });

            Assert.AreEqual(3, actual.Length);
            Assert.AreEqual(1L, actual[0]);
            Assert.AreEqual(2L, actual[1]);
            Assert.AreEqual(3L, actual[2]);
        }
예제 #3
0
        public void ToInt64_Representation_Int64()
        {
            var actual = BinaryStringRepresentation.ToInt64("1");

            Assert.AreEqual(1L, actual);

            actual = BinaryStringRepresentation.ToInt64("0000000000000001");
            Assert.AreEqual(1L, actual);

            actual = BinaryStringRepresentation.ToInt64("1010");
            Assert.AreEqual(10L, actual);
        }
예제 #4
0
        public void ToRepresentation_Int64_Representation()
        {
            var actual = BinaryStringRepresentation.ToRepresentation(1L);

            Assert.AreEqual("1", actual);

            actual = BinaryStringRepresentation.ToRepresentation(1L, 16);
            Assert.AreEqual("0000000000000001", actual);

            actual = BinaryStringRepresentation.ToRepresentation(10L);
            Assert.AreEqual("1010", actual);

            actual = BinaryStringRepresentation.ToRepresentation(360L);
            Assert.AreEqual("101101000", actual);

            for (long i = 0; i <= 360; i++)
            {
                var stringRepresentation = BinaryStringRepresentation.ToRepresentation(i, 9);
                Assert.AreEqual(9, stringRepresentation.Length);
                Assert.AreEqual(i, BinaryStringRepresentation.ToInt64(stringRepresentation));
            }
        }