From 0953236b4cd07a9f2f034dfc3ede7772608a747b Mon Sep 17 00:00:00 2001 From: Harshal <37841724+harshalkh@users.noreply.github.com> Date: Wed, 26 Oct 2022 12:48:33 +0530 Subject: [PATCH] Add tests for WordLadder (#3668) --- .../thealgorithms/strings/WordLadderTest.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/test/java/com/thealgorithms/strings/WordLadderTest.java diff --git a/src/test/java/com/thealgorithms/strings/WordLadderTest.java b/src/test/java/com/thealgorithms/strings/WordLadderTest.java new file mode 100644 index 00000000..4e1e1db6 --- /dev/null +++ b/src/test/java/com/thealgorithms/strings/WordLadderTest.java @@ -0,0 +1,17 @@ +package com.thealgorithms.strings; + +import static org.junit.jupiter.api.Assertions.*; + +import org.junit.jupiter.api.Test; +import java.util.*; + +public class WordLadderTest { + + @Test + public void testWordLadder() { + String words1[] = { "hot", "dot", "dog", "lot", "log", "cog" }; + assertEquals(5, WordLadder.ladderLength("hit", "cog", Arrays.asList(words1))); + String words2[] = { "hot", "dot", "dog", "lot", "log" }; + assertEquals(0, WordLadder.ladderLength("hit", "cog", Arrays.asList(words2))); + } +}