-
Notifications
You must be signed in to change notification settings - Fork 21.2k
Expand file tree
/
Copy pathTitleCaseTest.java
More file actions
34 lines (27 loc) · 1.03 KB
/
Copy pathTitleCaseTest.java
File metadata and controls
34 lines (27 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package com.thealgorithms.strings;
// author: Vraj Prajapati @Rosander0
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
public class TitleCaseTest {
@Test
public void testNullOrEmptyInputs() {
assertEquals("", TitleCase.toTitleCase(null));
assertEquals("", TitleCase.toTitleCase(""));
}
@Test
public void testSingleWord() {
assertEquals("Hello", TitleCase.toTitleCase("hello"));
assertEquals("Hello", TitleCase.toTitleCase("HELLO"));
assertEquals("A", TitleCase.toTitleCase("a"));
}
@Test
public void testMultipleWords() {
assertEquals("The Quick Brown Fox", TitleCase.toTitleCase("the quick brown fox"));
assertEquals("The Quick Brown Fox", TitleCase.toTitleCase("THE QUICK BROWN FOX"));
assertEquals("Already Title Case", TitleCase.toTitleCase("already Title Case"));
}
@Test
public void testWhitespace() {
assertEquals(" Spaces ", TitleCase.toTitleCase(" spaces "));
}
}