mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 17:22:09 +10:00
add unit test for LP switch
This commit is contained in:
@@ -22,14 +22,13 @@
|
||||
package org.diylc.netlist;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
|
||||
import org.diylc.components.electromechanical.OpenJack1_4;
|
||||
import org.diylc.components.guitar.HumbuckerPickup;
|
||||
import org.diylc.components.guitar.LPSwitch;
|
||||
import org.diylc.components.guitar.LeverSwitch;
|
||||
import org.diylc.components.guitar.LeverSwitch.LeverSwitchType;
|
||||
import org.diylc.components.guitar.SingleCoilPickup;
|
||||
@@ -315,4 +314,23 @@ public class GuitarNetlistAnalyzerTests {
|
||||
fail("Bad connection for p=" + p + ", i=" + i + ",j=" + j);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLPSwitch() {
|
||||
LPSwitch lpSwitch = new LPSwitch();
|
||||
String[] validCombinations = new String[] {
|
||||
"0,1,2", "1,1,2", "1,2,3", "1,1,3", "2,2,3"
|
||||
};
|
||||
Arrays.sort(validCombinations);
|
||||
for (int p = 0; p < lpSwitch.getPositionCount(); p++)
|
||||
for (int i = 0; i < lpSwitch.getControlPointCount(); i++)
|
||||
for (int j = 0; j < lpSwitch.getControlPointCount(); j++) {
|
||||
String test = p + "," + i + "," + j;
|
||||
boolean isConnected = lpSwitch.arePointsConnected(i, j, p);
|
||||
boolean isOk = (isConnected && Arrays.binarySearch(validCombinations, test) >= 0) ||
|
||||
!isConnected && Arrays.binarySearch(validCombinations, test) < 0;
|
||||
if (!isOk)
|
||||
fail("Bad connection for p=" + p + ", i=" + i + ",j=" + j);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user