fix: change location of others to correct places (#5559)

This commit is contained in:
B Karthik
2024-10-04 23:17:50 +05:30
committed by GitHub
parent 393337fa8e
commit 042d458d34
12 changed files with 42 additions and 21 deletions

View 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));
}
}