Exemplo n.º 1
0
        public void StringToInt_Positive()
        {
            StringToInt stringToInt = new StringToInt();
            var ret = stringToInt.Convert("+12345".ToCharArray());

            Assert.AreEqual(12345, ret);
        }
Exemplo n.º 2
0
        public void StringToInt_String()
        {
            StringToInt stringToInt = new StringToInt();
            var ret = stringToInt.Convert("a123".ToCharArray());

            Assert.AreEqual(0, ret);
        }
Exemplo n.º 3
0
        public void StringToInt_Max()
        {
            StringToInt stringToInt = new StringToInt();
            var ret = stringToInt.Convert("2147483647".ToCharArray());

            Assert.AreEqual(2147483647, ret);
        }
Exemplo n.º 4
0
        public void StringToInt()
        {
            StringToInt stringToInt = new StringToInt();
            var ret = stringToInt.Convert("1234567890".ToCharArray());

            Assert.AreEqual(1234567890, ret);
        }
Exemplo n.º 5
0
        public static void Main()
        {
            StringToInt sti = new StringToInt(CountChars);

            Console.WriteLine(sti.Invoke("I ate a bear. Who wins now huh?"));
            Console.WriteLine(sti.Invoke("I used to be a strong man, now I'm stronger!"));
            Console.WriteLine(sti.Invoke("I found money in my asscrack the other day. I suspect fame will reach me any moment now"));
            Console.WriteLine(DelegateUser(sti, "Yes baby, turn me into a pamphlet"));
            Console.ReadKey();
        }
Exemplo n.º 6
0
 public void StringToInt_OutofRange()
 {
     try
     {
         StringToInt stringToInt = new StringToInt();
         var ret = stringToInt.Convert("2147483649".ToCharArray());
     }
     catch (Exception ex)
     {
         Assert.AreEqual("Out", ex.Message);
     }
 }
Exemplo n.º 7
0
 static void Main(string[] args)
 {
     Question1.Test();
     EvaluateReversePolishNotation.Test();
     MedianTwoSortedArrays.Test();
     StringSum.Test();
     LongestSubstringWithoutRepeatingChar.Test();
     CustomSort.Test();
     MergeIntervals.Test();
     RegexMatch.Test();
     StringToInt.Test();
 }
Exemplo n.º 8
0
 public void WhiteSpacePrefixAndSuffix()
 {
     Assert.AreEqual(45735, StringToInt.Stoi("    zaf-=137198274nf", out var idx, 36));
     Assert.AreEqual("    zaf".Length, idx);
 }
Exemplo n.º 9
0
 public void Base0DetectBase16()
 {
     Assert.AreEqual(44810, StringToInt.Stoi("    0xAF0A-=137198274nf", out var idx, 0));
     Assert.AreEqual("    0xAF0A".Length, idx);
 }
Exemplo n.º 10
0
 public void HexaDecimal()
 {
     Assert.AreEqual(19918245, StringToInt.Stoi("12FEDA5", out var idx, 16));
     Assert.AreEqual("12FEDA5".Length, idx);
 }
Exemplo n.º 11
0
 public void Octal()
 {
     Assert.AreEqual(46396, StringToInt.Stoi("132474", out var idx, 8));
     Assert.AreEqual("132474".Length, idx);
 }
Exemplo n.º 12
0
 public void Decimal()
 {
     Assert.AreEqual(12345, StringToInt.Stoi("12345", out var idx, 10));
     Assert.AreEqual("12345".Length, idx);
 }
Exemplo n.º 13
0
 public static int DelegateUser(StringToInt toInt, string str)
 {
     return(toInt(str));
 }
Exemplo n.º 14
0
 public static int DelegateUser(this string s, StringToInt del)
 {
     return(del(s));
 }
Exemplo n.º 15
0
        public static int DelegateUser(StringToInt sti, string str)
        {
            int result = sti(str);

            return(result);
        }
Exemplo n.º 16
0
 public void Base0DetectDecimal()
 {
     Assert.AreEqual(3546752, StringToInt.Stoi("    3546752-=137198274nf", out var idx, 0));
     Assert.AreEqual("    3546752".Length, idx);
 }
Exemplo n.º 17
0
        public void StringToIntCorrectlyConvertsToJson()
        {
            var sti = new StringToInt();

            sti.ToString().ShouldEqual(StringToIntJson);
        }
Exemplo n.º 18
0
 //7
 public static int DelegateUser(StringToInt ST, string str)
 {
     return(ST(str));
 }