Example #1
0
 public void AtoiTests_NormalCases()
 {
     Assert.AreEqual(1234567, Atoi.Convert("1234567"));
     Assert.AreEqual(1234567, Atoi.Convert("+1234567"));
     Assert.AreEqual(-1234567, Atoi.Convert("-1234567"));
     Assert.AreEqual(34567, Atoi.Convert("0034567"));
     Assert.AreEqual(123, Atoi.Convert("+123dsds4567"));
 }
Example #2
0
 public void AtoiTests_CornerCases()
 {
     Assert.AreEqual(0, Atoi.Convert(null));
     Assert.AreEqual(0, Atoi.Convert(""));
     Assert.AreEqual(0, Atoi.Convert("       "));
     Assert.AreEqual(1, Atoi.Convert("       1"));
     Assert.AreEqual(1, Atoi.Convert("       1abc"));
     Assert.AreEqual(0, Atoi.Convert("       ab1"));
     Assert.AreEqual(1, Atoi.Convert("       +1"));
     Assert.AreEqual(-1, Atoi.Convert("       -1"));
     Assert.AreEqual(1, Atoi.Convert("+1"));
     Assert.AreEqual(-1, Atoi.Convert("-1"));
 }
Example #3
0
 public void Test(string input, int result)
 {
     Assert.Equal(result, Atoi.Convert(input));
 }
Example #4
0
 public void AtoiTests_OverflowCases()
 {
     Assert.AreEqual(int.MaxValue, Atoi.Convert("0909809809809"));
 }