Exemple #1
0
        public void UrlifyStringBuilderSoln()
        {
            string str = "Mr John Smith        ";

            char[] strChar = str.ToCharArray();
            Assert.AreEqual(URLify.ReplaceSpacesUsingStringBuilder(strChar, 13), "Mr%20John%20Smith");
        }
Exemple #2
0
        public void RunTest01()
        {
            URLify test   = new URLify("Hello There  ".ToCharArray(), 11);
            var    result = test.Run();

            CollectionAssert.AreEqual(Test01Result, result);
        }
        private static string ReplaceSpaceWithPercent20()
        {
            URLify uf  = new URLify();
            string str = "My name is Kunal.   ";

            return(uf.ReplaceSpaceWithPercent20(str, 17));
        }
Exemple #4
0
        public void FirstTry_With_Less_Spaces_Than_Necessary()
        {
            string input = "Mr John Smith   ";

            string output = new URLify().FirstTry(input);

            Assert.Equal("Mr%20John%20Smit", output);
        }
Exemple #5
0
        public void FirstTry_URLify_The_Parameter()
        {
            string input = "Mr John Smith    ";

            string output = new URLify().FirstTry(input);

            Assert.Equal("Mr%20John%20Smith", output);
        }
        public void Given_String_Return_URLified_String()
        {
            string s        = "Mr John Smith             ";
            int    length   = 13;
            var    actual   = URLify.URLifyString(s, length);
            var    expected = "Mr%20John%20Smith";

            Assert.Equal(actual, expected);
        }
Exemple #7
0
        public void UrlifyCTCISoln()
        {
            string str = "Mr John Smith        ";

            char[] strChar = str.ToCharArray();
            URLify.ReplaceSpaces(strChar, 13);
            // if i do not trim the result, it would fail since there will be remaining spaces to handle
            var ans = new String(strChar).Trim();

            Assert.AreEqual(ans, "Mr%20John%20Smith");
        }
Exemple #8
0
        public void URLify_Tests()
        {
            var input       = new char[100];
            var inputString = "Mr John Smith";

            for (int i = 0; i < inputString.Length; i++)
            {
                input[i] = inputString[i];
            }

            var result = URLify.URLifyAlgo(input, 13);

            (new string(result)).TrimEnd('\0').Should().Be("Mr%20John%20Smith");
        }
        static void Main(string[] args)
        {
            //Problems.PrintSquares(1000000);

            //int[] arr = new int[7] { 3, 4, 2, 1, 5, 4, 9 };
            // SortingAlgos.MergeSort(arr, 0, arr.Length -1);
            //for (int i = 0; i < arr.Length; i++)
            //{
            //    Console.Write($"{arr[i]} ");
            //}


            char[] str = "Mr John Smith ".ToCharArray();

            // Prints the replaced string
            str = URLify.replaceSpaces(str);

            for (int i = 0; i < str.Length; i++)
            {
                Console.Write(str[i]);
            }

            Console.ReadKey();
        }
        static void Main(string[] args)
        {
            var condition = true;

            //just keeping the current solving problem in if condition; nothing else
            if (condition)
            {
                KStacks.MainMethod();
            }
            else
            {
                #region LinkedLists
                LinkIntersection.MainMethod();
                SumList.MainMethod();
                RemoveDups <int> .MainMethod();

                ReturnKthToLast.MainMethod(1);
                DeleteMiddleNode.MainMethod();
                LoopDetection.MainMethod();
                #endregion

                #region Array and Strings
                StringRotation.IsStringRotation("waterbottle", "erbottlewat");
                ZeroMatrixImplementation();
                RotateMatrixImplementation(4);
                StringCompression.CompressedString("aabcccccaaa");
                OneAway.IsStringOneAway("pale", "paled");
                PalindromePermutation.IsPalindromePermutation("Mr. owl ate my Metal worm");
                URLify.URLifyString("Spaces in this string will be replaced by percent20");
                IsStringPermutation.VerifyStringPermutation("abdcdefgh", "aefgb2cdh");
                UniqueString.VerifyUniqueStringAsciiSet("!@#$%$^&*()EFgh");
                HashTableImplentation();
                SwapWithoutTemp.SwapWithoutTempVar(12, 24);
                #endregion
            }
        }
Exemple #11
0
 public void Setup()
 {
     uRLify = new URLify();
 }
Exemple #12
0
 public void ToUrlStartFromEnd(string s, int len, string expected)
 {
     Assert.Equal(expected, URLify.ToUrlStartFromEnd(s, len));
 }
Exemple #13
0
        public void URLifyWithCountTest(string input, int length, string expectedResult)
        {
            var result = URLify.RunWithLength(input.ToCharArray(), length);

            Assert.Equal(expectedResult, result);
        }
Exemple #14
0
        public void URLifyTest(string input, string expectedResult)
        {
            var result = URLify.Run(input);

            Assert.Equal(expectedResult, result);
        }
Exemple #15
0
 public void InitURLify()
 {
     _str = new URLify();
 }
 public URLify_DoShould()
 {
     _sut = new URLify();
 }