mirror of
https://github.com/TheAlgorithms/Java.git
synced 2026-03-13 08:40:43 +08:00
fix: change location of others to correct places (#5559)
This commit is contained in:
24
src/test/java/com/thealgorithms/strings/CountCharTest.java
Normal file
24
src/test/java/com/thealgorithms/strings/CountCharTest.java
Normal file
@@ -0,0 +1,24 @@
|
||||
package com.thealgorithms.strings;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.CsvSource;
|
||||
|
||||
class CountCharTest {
|
||||
|
||||
@ParameterizedTest(name = "\"{0}\" should have {1} non-whitespace characters")
|
||||
@CsvSource({"'', 0", "' ', 0", "'a', 1", "'abc', 3", "'a b c', 3", "' a b c ', 3", "'\tabc\n', 3", "' a b\tc ', 3", "' 12345 ', 5", "'Hello, World!', 12"})
|
||||
@DisplayName("Test countCharacters with various inputs")
|
||||
void testCountCharacters(String input, int expected) {
|
||||
assertEquals(expected, CountChar.countCharacters(input));
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Test countCharacters with null input")
|
||||
void testCountCharactersNullInput() {
|
||||
assertEquals(0, CountChar.countCharacters(null));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user