Add oving 5

This commit is contained in:
Andreas Omholt Olsen
2026-02-09 15:28:09 +01:00
parent 6193e26ba1
commit 55c36a603a
33 changed files with 1586 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
package oving5.twitter;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
public class UserNameComparatorTest {
private TwitterAccount aaron1;
private TwitterAccount aaron2;
private TwitterAccount ben;
private UserNameComparator comparator;
@BeforeEach
public void setUp() {
aaron1 = new TwitterAccount("Aaron");
aaron2 = new TwitterAccount("Aaron");
ben = new TwitterAccount("Ben");
comparator = new UserNameComparator();
}
@Test
@DisplayName("Check comparison based on username")
public void testCompare() {
assertTrue(comparator.compare(aaron1, ben) < 0, "Aaron should be sorted before Ben");
assertTrue(comparator.compare(ben, aaron1) > 0, "Ben should be sorted after Aaron");
assertEquals(comparator.compare(aaron1, aaron2), 0,
"Two people with the same name should be equal");
}
}