Create Atoi Function.java (#3756)

* Create MyAtoi.java

There is a method in C++, which converts String to an Integer, called Atoi function, this is my own implementation of this function.

* Update directory

* Update MyAtoi.java

* Create MyAtoiTest.java

* Update directory

* Update directory

* Update directory

* Update MyAtoi.java

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Debasish Biswas <debasishbsws.abc@gmail.com>
This commit is contained in:
Aidar Djamalbek
2022-11-01 17:04:14 +06:00
committed by GitHub
parent d418bbd1cf
commit fea982d54d
3 changed files with 235 additions and 61 deletions

View File

@ -0,0 +1,25 @@
package com.thealgorithms.strings;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
public class MyAtoiTest {
@Test
void testOne() {
assertEquals(42, MyAtoi.myAtoi("42"));
}
@Test
void testTwo() {
assertEquals(-42, MyAtoi.myAtoi(" -42"));
}
@Test
void testThree() {
assertEquals(4193, MyAtoi.myAtoi("4193 with words"));
}
}