mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-21 02:53:15 +08:00
Format code with prettier (#3375)
This commit is contained in:
@ -1,7 +1,6 @@
|
||||
package com.thealgorithms.searches;
|
||||
|
||||
import com.thealgorithms.searches.DepthFirstSearch.Node;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
@ -38,24 +37,33 @@ public class BreadthFirstSearch {
|
||||
|
||||
public static void assertThat(final Object actual, final Object expected) {
|
||||
if (!Objects.equals(actual, expected)) {
|
||||
throw new AssertionError(String.format("expected=%s but was actual=%s", expected, actual));
|
||||
throw new AssertionError(
|
||||
String.format("expected=%s but was actual=%s", expected, actual)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(final String[] args) {
|
||||
final Node rootNode = new Node("A", List.of(
|
||||
new Node("B", List.of(new Node("D"), new Node("F", List.of(
|
||||
new Node("H"), new Node("I")
|
||||
)))),
|
||||
final Node rootNode = new Node(
|
||||
"A",
|
||||
List.of(
|
||||
new Node(
|
||||
"B",
|
||||
List.of(
|
||||
new Node("D"),
|
||||
new Node("F", List.of(new Node("H"), new Node("I")))
|
||||
)
|
||||
),
|
||||
new Node("C", List.of(new Node("G"))),
|
||||
new Node("E")
|
||||
));
|
||||
)
|
||||
);
|
||||
|
||||
{
|
||||
final String expected = "I";
|
||||
|
||||
final Node result = search(rootNode, expected)
|
||||
.orElseThrow(() -> new AssertionError("Node not found!"));
|
||||
.orElseThrow(() -> new AssertionError("Node not found!"));
|
||||
|
||||
assertThat(result.getName(), expected);
|
||||
}
|
||||
@ -64,7 +72,7 @@ public class BreadthFirstSearch {
|
||||
final String expected = "G";
|
||||
|
||||
final Node result = search(rootNode, expected)
|
||||
.orElseThrow(() -> new AssertionError("Node not found!"));
|
||||
.orElseThrow(() -> new AssertionError("Node not found!"));
|
||||
|
||||
assertThat(result.getName(), expected);
|
||||
}
|
||||
@ -73,7 +81,7 @@ public class BreadthFirstSearch {
|
||||
final String expected = "E";
|
||||
|
||||
final Node result = search(rootNode, expected)
|
||||
.orElseThrow(() -> new AssertionError("Node not found!"));
|
||||
.orElseThrow(() -> new AssertionError("Node not found!"));
|
||||
|
||||
assertThat(result.getName(), expected);
|
||||
}
|
||||
|
Reference in New Issue
Block a user