mirror of
https://github.com/Snailclimb/JavaGuide
synced 2025-06-16 18:10:13 +08:00
Test Backtracking NQueens
This commit is contained in:
parent
7e2b3e0742
commit
156befeba9
26
docs/test/test_backtracking_nqueen.jav
Normal file
26
docs/test/test_backtracking_nqueen.jav
Normal file
@ -0,0 +1,26 @@
|
||||
package com.gpcoder.junit.util;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
public class solveNQueensTest {
|
||||
public void dfsTest() {
|
||||
List<List<String>> resultList = new LinkedList<>();
|
||||
final int[] expected = [2, 4, 6, 8, 3, 1, 7, 5];
|
||||
final int[] result = new int[8];
|
||||
dfs(resultList, result, 0, 8);
|
||||
Assert.assertArrayEquals(expected, result);
|
||||
}
|
||||
public void dfsTest2() {
|
||||
List<List<String>> resultList = new LinkedList<>();
|
||||
final int[] expected = [2, 4, 1, 3];
|
||||
final int[] result = new int[4];
|
||||
dfs(resultList, result, 0, 4);
|
||||
Assert.assertArrayEquals(expected, result);
|
||||
}
|
||||
public void dfsTest3() {
|
||||
List<List<String>> resultList = new LinkedList<>();
|
||||
final int[] expected = [];
|
||||
final int[] result = new int[3];
|
||||
dfs(resultList, result, 0, 3);
|
||||
Assert.assertArrayEquals(expected, result);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user