From ef9e61de336f3c6463fda68422a8f492a2ae5a90 Mon Sep 17 00:00:00 2001 From: Graham Date: Mon, 26 Aug 2019 14:39:05 +0100 Subject: [PATCH] Add StringUtilsTest --- util/pom.xml | 4 ++++ .../dev/openrs2/util/StringUtilsTest.java | 21 +++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 util/src/test/java/dev/openrs2/util/StringUtilsTest.java diff --git a/util/pom.xml b/util/pom.xml index ca80cf3c..f1b85306 100644 --- a/util/pom.xml +++ b/util/pom.xml @@ -27,5 +27,9 @@ org.slf4j slf4j-api + + org.junit.jupiter + junit-jupiter + diff --git a/util/src/test/java/dev/openrs2/util/StringUtilsTest.java b/util/src/test/java/dev/openrs2/util/StringUtilsTest.java new file mode 100644 index 00000000..eafa8e2d --- /dev/null +++ b/util/src/test/java/dev/openrs2/util/StringUtilsTest.java @@ -0,0 +1,21 @@ +package dev.openrs2.util; + +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; + +public final class StringUtilsTest { + @Test + public void testIndefiniteArticle() { + assertEquals("a", StringUtils.indefiniteArticle("book")); + assertEquals("an", StringUtils.indefiniteArticle("aeroplane")); + + assertThrows(IllegalArgumentException.class, () -> StringUtils.indefiniteArticle("")); + } + + @Test + public void testCapitalize() { + assertEquals("Hello", StringUtils.capitalize("hello")); + assertEquals("", StringUtils.capitalize("")); + } +}