mirror of
https://github.com/TheAlgorithms/Java.git
synced 2026-02-04 04:23:32 +08:00
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:
25
src/test/java/com/thealgorithms/strings/MyAtoiTest.java
Normal file
25
src/test/java/com/thealgorithms/strings/MyAtoiTest.java
Normal 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"));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user