コード例 #1
0
        public void FindNextSmallerNumberTest(uint testNumber, uint expectedNumber)
        {
            // Act
            uint resultNumber = Question_5_4.FindNextSmallerNumber(testNumber);

            // Assert
            Assert.AreEqual(expectedNumber, resultNumber, $"Failed to find the next smaller number of {testNumber}.");
        }
コード例 #2
0
        public void FindNextSmallerNumberTest_EdgeCases(uint testNumber)
        {
            try
            {
                // Act
                Question_5_4.FindNextSmallerNumber(testNumber);

                // Assert
                Assert.Fail("Edge case check failed.");
            }
            catch (ArgumentException e)
            {
                Assert.AreEqual($"There is no smaller number with same number of 1s as {testNumber}.", e.Message, "Incorrect exception caught.");
            }
        }