Exemplo n.º 1
0
        public void StrStrTest3()
        {
            var input1   = "";
            var input2   = "";
            var expected = 0;

            ImplementstrStr.StrStr(input1, input2).Should().Be(expected);
        }
Exemplo n.º 2
0
        public void StrStrTest()
        {
            var input1   = "hello";
            var input2   = "ll";
            var expected = 2;

            ImplementstrStr.StrStr(input1, input2).Should().Be(expected);
        }
Exemplo n.º 3
0
        public void StrStrTest2()
        {
            var input1   = "aaaaa";
            var input2   = "bba";
            var expected = -1;

            ImplementstrStr.StrStr(input1, input2).Should().Be(expected);
        }
Exemplo n.º 4
0
        public void ImplementstrStrTest()
        {
            var c = new ImplementstrStr();

            // example1
            var haystack = "hello";
            var needle   = "ll";

            var result = c.StrStr(haystack, needle);

            Assert.AreEqual(result, 2);

            // example2
            haystack = "aaaaa"; needle = "bba";
            result   = c.StrStr(haystack, needle);
            Assert.AreEqual(result, -1);

            //example3
            haystack = ""; needle = "";
            result   = c.StrStr(haystack, needle);
            Assert.AreEqual(result, 0);
        }