-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1eee1b1
commit 19368c9
Showing
8 changed files
with
256 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
package fabulator.object; | ||
|
||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
public class LocationTest { | ||
|
||
@Test | ||
@DisplayName("Test creation of Location objects") | ||
public void testCreationOfLocationObjects() { | ||
Location l1 = new Location(1,2); | ||
Location l2 = new Location (42.0, 6.9); | ||
|
||
assertEquals(1, l1.getX()); | ||
assertEquals(2, l1.getY()); | ||
|
||
assertEquals(42.0, l2.getX()); | ||
assertEquals(6.9, l2.getY()); | ||
|
||
assertTrue(l1.valid()); | ||
assertTrue(l2.valid()); | ||
} | ||
|
||
@Test | ||
@DisplayName("Test comparison of Location objects") | ||
public void testComparisonOfLocationObjects() { | ||
Location l1 = new Location(12.3, 4.56); | ||
Location l2 = new Location(12.3, 4.56); | ||
Location l3 = new Location(12.34, 4.56); | ||
|
||
assertEquals(l1, l2); | ||
assertNotEquals(l2, l3); | ||
} | ||
|
||
@Test | ||
@DisplayName("Test invalid Location") | ||
public void testInvalidLocation() { | ||
Location l1 = new Location(Double.NaN,12.3456); | ||
Location l2 = new Location(1, Double.NaN); | ||
|
||
assertFalse(l1.valid()); | ||
assertFalse(l2.valid()); | ||
} | ||
|
||
@Test | ||
@DisplayName("Test adding Location objects") | ||
public void testAddingLocationObjects() { | ||
Location l1 = new Location(-1, 2); | ||
Location l2 = new Location(44, 33); | ||
|
||
l1.add(l2); | ||
assertEquals(43, l1.getX()); | ||
assertEquals(35, l1.getY()); | ||
|
||
l2.add(-1, 1); | ||
assertEquals(43, l2.getX()); | ||
assertEquals(34, l2.getY()); | ||
} | ||
|
||
@Test | ||
@DisplayName("Test scaleInverse method of Location") | ||
public void testScaleInverseMethodOfLocation() { | ||
Location l1 = new Location(3, 6); | ||
Location l2 = new Location(123, -123); | ||
|
||
l1.scaleInverse(3); | ||
l2.scaleInverse(7); | ||
|
||
assertEquals(1, l1.getX()); | ||
assertEquals(2, l1.getY()); | ||
|
||
assertEquals(123d/7d, l2.getX()); | ||
assertEquals(-123d/7d, l2.getY()); | ||
} | ||
|
||
@Test | ||
@DisplayName("Test average of Location objects") | ||
public void testAverageOfLocationObjects() { | ||
Location l1 = new Location(0, 22); | ||
Location l2 = new Location(-14, 7); | ||
Location l3 = new Location(3, -2); | ||
|
||
assertEquals(l1, Location.averageOf(l1)); | ||
assertEquals(l2, Location.averageOf(l2)); | ||
|
||
Location totalAverage = Location.averageOf(l1, l2, l3); | ||
|
||
assertEquals(-11d/3d, totalAverage.getX()); | ||
assertEquals(27d/3d, totalAverage.getY()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package fabulator.object; | ||
|
||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
public class VersionTest { | ||
|
||
@Test | ||
@DisplayName("Test creating Version from String") | ||
public void testCreateVersionFromString() { | ||
Version v1 = new Version("1.2.3"); | ||
|
||
assertEquals(1, v1.getMajor()); | ||
assertEquals(2, v1.getMinor()); | ||
assertEquals(3, v1.getPatch()); | ||
|
||
Version v2 = new Version("3.22.111"); | ||
|
||
assertEquals(3, v2.getMajor()); | ||
assertEquals(22, v2.getMinor()); | ||
assertEquals(111, v2.getPatch()); | ||
} | ||
|
||
@Test | ||
@DisplayName("Test comparing Version objects") | ||
public void testComparingVersionObjects() { | ||
Version v1 = new Version("1.2.3"); | ||
Version v2 = new Version("1.2.3"); | ||
Version v3 = new Version("2.2.4"); | ||
Version v4 = new Version("0.99.99"); | ||
Version v5 = new Version("0.100.0"); | ||
|
||
assertFalse(Version.outdated(v1, v2)); | ||
assertFalse(Version.outdated(v1, v3)); | ||
assertTrue(Version.outdated(v3, v1)); | ||
assertTrue(Version.outdated(v1, v4)); | ||
assertFalse(Version.outdated(v4, v5)); | ||
assertTrue(Version.outdated(v5, v4)); | ||
} | ||
|
||
@Test | ||
@DisplayName("Test Version to String conversion") | ||
public void testVersionToStringConversion() { | ||
assertEquals("1.2.3", new Version("1.2.3").toString()); | ||
assertEquals("1.22.333", new Version("1.22.333").toString()); | ||
assertEquals("4.0.4", new Version("4.0.4").toString()); | ||
assertEquals("0.0.0", new Version("0.0.0").toString()); | ||
} | ||
|
||
@Test | ||
@DisplayName("Test Version creation with faulty input") | ||
public void testVersionCreationWithFaultyInput() { | ||
assertThrows(NumberFormatException.class, () -> new Version("a.b.c")); | ||
assertThrows(NumberFormatException.class, () -> new Version("1.2.3.4")); | ||
assertThrows(NumberFormatException.class, () -> new Version("5.6")); | ||
assertThrows(NumberFormatException.class, () -> new Version("")); | ||
assertThrows(NumberFormatException.class, () -> new Version(null)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package fabulator.parse; | ||
|
||
import fabulator.lookup.BitstreamConfiguration; | ||
import fabulator.lookup.Net; | ||
import fabulator.object.DiscreteLocation; | ||
import javafx.util.Pair; | ||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.net.URL; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
public class FasmParserTest { | ||
|
||
private static BitstreamConfiguration config; | ||
|
||
@BeforeAll | ||
@DisplayName("Test parsing fasm file") | ||
public static void testParsingFasmFile() { | ||
URL fasmSourceUrl = FasmParserTest.class.getResource("/parse/test_user_design.fasm"); | ||
assertNotNull(fasmSourceUrl); | ||
|
||
String fileName = fasmSourceUrl.getFile(); | ||
FasmParser parser = new FasmParser(fileName); | ||
|
||
config = parser.getConfig(); | ||
} | ||
|
||
@Test | ||
@DisplayName("Test FasmParser correctness") | ||
public void testFasmParserCorrectness() { | ||
Net n1 = config.getNetMap().get("test_net_1"); | ||
Net n2 = config.getNetMap().get("test_net_2"); | ||
Net n3 = config.getNetMap().get("test_net_3"); | ||
|
||
assertEquals(4, n1.getEntries().size()); | ||
assertEquals(0, n2.getEntries().size()); | ||
assertEquals(2, n3.getEntries().size()); | ||
|
||
Pair<DiscreteLocation, BitstreamConfiguration.ConnectedPorts> firstEntry; | ||
firstEntry = n1.getEntries().get(0); | ||
|
||
DiscreteLocation firstLocation = firstEntry.getKey(); | ||
String portA = firstEntry.getValue().getPortA(); | ||
String portB = firstEntry.getValue().getPortB(); | ||
|
||
assertEquals(0, firstLocation.getX()); | ||
assertEquals(1, firstLocation.getY()); | ||
assertEquals("test_port_1", portA); | ||
assertEquals("test_port_2", portB); | ||
} | ||
} |
3 changes: 1 addition & 2 deletions
3
...t/java/fabulator/builder/BuilderTest.java → ...ava/fabulator/ui/builder/BuilderTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# routing for net 'test_net_1' | ||
X0Y1.test_port_1.test_port_2 | ||
X0Y1.test_port_2.test_port_3 | ||
X2Y1.test_port_1.test_port_4 | ||
X0Y3.test_port_5.test_port_7 | ||
|
||
# routing for net 'test_net_2' | ||
|
||
# routing for net 'test_net_3' | ||
X11Y1.test_port_4.test_port_1 | ||
X7Y13.test_port7.test_port_6 |