コード例 #1
0
 public void TestInvertCase()
 {
     Assertions.AssertEquals('X', InvertCase('x'));
     Assertions.AssertEquals('k', InvertCase('K'));
     Assertions.AssertEquals('C', InvertCase('c'));
     Assertions.AssertEquals('d', InvertCase('D'));
 }
コード例 #2
0
 public void TestToUppercase()
 {
     Assertions.AssertEquals('X', ToUppercase('x'));
     Assertions.AssertEquals('K', ToUppercase('k'));
     Assertions.AssertEquals('C', ToUppercase('c'));
     Assertions.AssertEquals('D', ToUppercase('d'));
 }
コード例 #3
0
 public void TestToLowercase()
 {
     Assertions.AssertEquals('x', ToLowercase('X'));
     Assertions.AssertEquals('k', ToLowercase('K'));
     Assertions.AssertEquals('c', ToLowercase('C'));
     Assertions.AssertEquals('d', ToLowercase('D'));
 }
コード例 #4
0
        public void TestXorSwap()
        {
            var first  = 621;
            var second = 2048;

            XorSwap(ref first, ref second);

            Assertions.AssertEquals(2048, first);
            Assertions.AssertEquals(621, second);
        }
コード例 #5
0
        public void TestGetPositionOfRightmostBit()
        {
            var n1 = 0b1001;
            var n2 = 0b0000;
            var n3 = 0b10100;
            var n4 = 0b11000;

            Assertions.AssertEquals(0b1, GetPositionOfRightmostBit(n1));
            Assertions.AssertEquals(0, GetPositionOfRightmostBit(n2));
            Assertions.AssertEquals(0b100, GetPositionOfRightmostBit(n3));
            Assertions.AssertEquals(0b1000, GetPositionOfRightmostBit(n4));
        }
コード例 #6
0
        public void TestFindPositionInAlphabet()
        {
            Assertions.AssertEquals(26, FindPositionInAlphabet('z'));
            Assertions.AssertEquals(26, FindPositionInAlphabet('Z'));

            Assertions.AssertEquals(1, FindPositionInAlphabet('a'));
            Assertions.AssertEquals(1, FindPositionInAlphabet('A'));

            Assertions.AssertEquals(5, FindPositionInAlphabet('e'));
            Assertions.AssertEquals(5, FindPositionInAlphabet('E'));

            Assertions.AssertEquals(10, FindPositionInAlphabet('j'));
            Assertions.AssertEquals(10, FindPositionInAlphabet('J'));
        }
コード例 #7
0
        public void TestIncrement()
        {
            var v1 = 100;
            var v2 = 15;
            var v3 = -44;

            Increment(ref v1);

            Increment(ref v2);
            Increment(ref v2);

            Increment(ref v3);
            Increment(ref v3);
            Increment(ref v3);

            Assertions.AssertEquals(101, v1);
            Assertions.AssertEquals(17, v2);
            Assertions.AssertEquals(-41, v3);
        }