|
| 1 | +using System; |
| 2 | +using Algorithms.Other; |
| 3 | +using NUnit.Framework; |
| 4 | + |
| 5 | +namespace Algorithms.Tests.Other |
| 6 | +{ |
| 7 | + public static class Int2BinaryTests |
| 8 | + { |
| 9 | + [Test] |
| 10 | + [TestCase((UInt16) 0, "0000000000000000")] |
| 11 | + [TestCase((UInt16) 0b1, "0000000000000001")] |
| 12 | + [TestCase((UInt16) 0b0001010100111000, "0001010100111000")] |
| 13 | + [TestCase((UInt16) 0b1110111100110010, "1110111100110010")] |
| 14 | + [TestCase((UInt16)(UInt16.MaxValue - 1), "1111111111111110")] |
| 15 | + [TestCase(UInt16.MaxValue , "1111111111111111")] |
| 16 | + public static void GetsBinary(UInt16 input, string expected) |
| 17 | + { |
| 18 | + // Arrange |
| 19 | + |
| 20 | + // Act |
| 21 | + var result = Int2Binary.Int2bin(input); |
| 22 | + |
| 23 | + // Assert |
| 24 | + Assert.AreEqual(expected, result); |
| 25 | + } |
| 26 | + |
| 27 | + |
| 28 | + [Test] |
| 29 | + [TestCase((UInt32)0, "00000000000000000000000000000000")] |
| 30 | + [TestCase((UInt32)0b1, "00000000000000000000000000000001")] |
| 31 | + [TestCase((UInt32)0b0001010100111000, "00000000000000000001010100111000")] |
| 32 | + [TestCase((UInt32)0b1110111100110010, "00000000000000001110111100110010")] |
| 33 | + [TestCase((UInt32)0b10101100001110101110111100110010, "10101100001110101110111100110010")] |
| 34 | + [TestCase((UInt32)(UInt32.MaxValue - 1), "11111111111111111111111111111110")] |
| 35 | + [TestCase(UInt32.MaxValue, "11111111111111111111111111111111")] |
| 36 | + public static void GetsBinary(UInt32 input, string expected) |
| 37 | + { |
| 38 | + // Arrange |
| 39 | + |
| 40 | + // Act |
| 41 | + var result = Int2Binary.Int2bin(input); |
| 42 | + |
| 43 | + // Assert |
| 44 | + Assert.AreEqual(expected, result); |
| 45 | + } |
| 46 | + |
| 47 | + [Test] |
| 48 | + [TestCase((UInt64)0, "0000000000000000000000000000000000000000000000000000000000000000")] |
| 49 | + [TestCase((UInt64)0b1, "0000000000000000000000000000000000000000000000000000000000000001")] |
| 50 | + [TestCase((UInt64)0b0001010100111000, "0000000000000000000000000000000000000000000000000001010100111000")] |
| 51 | + [TestCase((UInt64)0b1110111100110010, "0000000000000000000000000000000000000000000000001110111100110010")] |
| 52 | + [TestCase((UInt64)0b10101100001110101110111100110010, "0000000000000000000000000000000010101100001110101110111100110010")] |
| 53 | + [TestCase((UInt64)0b1000101110100101000011010101110101010101110101001010000011111000, "1000101110100101000011010101110101010101110101001010000011111000")] |
| 54 | + [TestCase((UInt64)(UInt64.MaxValue - 1), "1111111111111111111111111111111111111111111111111111111111111110")] |
| 55 | + [TestCase(UInt64.MaxValue, "1111111111111111111111111111111111111111111111111111111111111111")] |
| 56 | + public static void GetsBinary(UInt64 input, string expected) |
| 57 | + { |
| 58 | + // Arrange |
| 59 | + |
| 60 | + // Act |
| 61 | + var result = Int2Binary.Int2bin(input); |
| 62 | + |
| 63 | + // Assert |
| 64 | + Assert.AreEqual(expected, result); |
| 65 | + } |
| 66 | + |
| 67 | + } |
| 68 | +} |
0 commit comments