test coverage for existing class
This commit is contained in:
parent
d3cb865e3e
commit
7cfa70740f
|
@ -84,7 +84,7 @@ public class PcbMergeTool {
|
|||
return null;
|
||||
}
|
||||
|
||||
static void mergePcb(PcbNode destNode, PcbNode source) throws IOException {
|
||||
static void mergePcb(PcbNode destNode, PcbNode source) {
|
||||
/**
|
||||
* original local net name > new net name in combined PCB
|
||||
*/
|
||||
|
@ -219,13 +219,17 @@ public class PcbMergeTool {
|
|||
net.setString(1, globalName);
|
||||
}
|
||||
|
||||
private static class Networks {
|
||||
public static class Networks {
|
||||
/**
|
||||
* Net name > Net Id
|
||||
*/
|
||||
private Map<String, Integer> networks = new HashMap<>();
|
||||
private Map<Integer, String> nameById = new HashMap<>();
|
||||
private final Map<String, Integer> networks = new HashMap<>();
|
||||
private final Map<Integer, String> nameById = new HashMap<>();
|
||||
|
||||
/**
|
||||
* @param name current name
|
||||
* @return new name for local network
|
||||
*/
|
||||
public String registerNetworkIfPcbSpecific(String name) {
|
||||
if (isLocalNetwork(name)) {
|
||||
String newName = "F-0000" + networks.size();
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package com.rusefi.pcb.nodes;
|
||||
|
||||
import com.rusefi.pcb.nodes.PcbNode;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
package com.rusefi.pcb;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class NetworksTest {
|
||||
|
||||
private static final String GND = "GND";
|
||||
|
||||
@Test(expected = NullPointerException.class)
|
||||
public void testNonExistent() {
|
||||
PcbMergeTool.Networks n = new PcbMergeTool.Networks();
|
||||
|
||||
n.getId(GND);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRegister() {
|
||||
PcbMergeTool.Networks n = new PcbMergeTool.Networks();
|
||||
|
||||
n.registerNetworkIfPcbSpecific(GND);
|
||||
assertEquals(0, n.getId(GND));
|
||||
|
||||
n.registerNetworkIfPcbSpecific(GND);
|
||||
assertEquals(0, n.getId(GND));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLocalNetwork() {
|
||||
PcbMergeTool.Networks n = new PcbMergeTool.Networks();
|
||||
n.registerNetworkIfPcbSpecific(GND);
|
||||
|
||||
String newName = n.registerNetworkIfPcbSpecific("N-00239");
|
||||
assertEquals("F-00001", newName);
|
||||
assertEquals(1, n.getId(newName));
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue