Skip to content

Commit

Permalink
fixed a testing bug which causes two HighZ values to be not equal.
Browse files Browse the repository at this point in the history
  • Loading branch information
hneemann committed Aug 22, 2016
1 parent b92a96b commit c53c522
Show file tree
Hide file tree
Showing 4 changed files with 126 additions and 3 deletions.
22 changes: 21 additions & 1 deletion src/main/java/de/neemann/digital/gui/components/test/Value.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,24 @@ public class Value {
/**
* Types of values
*/
public enum Type {NORMAL, DONTCARE, HIGHZ, CLOCK}
public enum Type {
/**
* normal value, value is stored in member variable value
*/
NORMAL,
/**
* Value don't care in test
*/
DONTCARE,
/**
* value is "high impedance"
*/
HIGHZ,
/**
* its a clock value which is handled as a 0-1-0 sequence
*/
CLOCK
}

private final long value;
private final Type type;
Expand Down Expand Up @@ -71,6 +88,9 @@ public boolean isEqualTo(Value v) {

if (v.type != type) return false;

// both types are equal!
if (type == Type.HIGHZ) return true;

return value == v.value;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public void testResultError() throws Exception {
assertEquals(false, ((MatchedValue)tr.getValue(3,2)).isPassed());
}

public void testResultErrorDC() throws Exception {
public void testResultDontCare() throws Exception {
Model model = getModel("A+B");
TestData data = new TestData(
"A B Y\n"
Expand All @@ -73,4 +73,16 @@ public void testResultErrorDC() throws Exception {
assertTrue(tr.allPassed());
}

public void testResultDontCare2() throws Exception {
Model model = getModel("A+B");
TestData data = new TestData(
"A B Y\n"
+ "0 0 x\n"
+ "0 1 1\n"
+ "1 0 1\n"
+ "1 1 1\n");
TestResult tr = new TestResult(data).create(model);
assertTrue(tr.allPassed());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,13 @@ public void testTestableDist() throws Exception {

public void testTestableTest() throws Exception {
File examples = new File(Resources.getRoot(), "/dig/test");
assertEquals(2, new FileScanner(this::check).scan(examples));
assertEquals(3, new FileScanner(this::check).scan(examples));
}

// public void testFile() throws Exception {
// check(new File(Resources.getRoot(), "/dig/test/highz.dig"));
// }

/**
* Loads the model and initializes and tests it
*
Expand Down
87 changes: 87 additions & 0 deletions src/test/resources/dig/test/highz.dig
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<?xml version="1.0" encoding="utf-8"?>
<circuit>
<version>1</version>
<visualElements>
<visualElement>
<elementName>Driver</elementName>
<elementAttributes>
<entry>
<string>flipSelPos</string>
<boolean>true</boolean>
</entry>
</elementAttributes>
<pos x="360" y="300"/>
</visualElement>
<visualElement>
<elementName>In</elementName>
<elementAttributes>
<entry>
<string>Label</string>
<string>I</string>
</entry>
</elementAttributes>
<pos x="300" y="300"/>
</visualElement>
<visualElement>
<elementName>In</elementName>
<elementAttributes>
<entry>
<string>Label</string>
<string>en</string>
</entry>
</elementAttributes>
<pos x="300" y="340"/>
</visualElement>
<visualElement>
<elementName>Out</elementName>
<elementAttributes>
<entry>
<string>Label</string>
<string>O</string>
</entry>
</elementAttributes>
<pos x="420" y="300"/>
</visualElement>
<visualElement>
<elementName>Testcase</elementName>
<elementAttributes>
<entry>
<string>Label</string>
<string>High Z</string>
</entry>
<entry>
<string>Testdata</string>
<testData>
<dataString>I en O
1 1 1
0 1 0
1 0 Z
0 0 Z
1 0 X
0 0 X
</dataString>
</testData>
</entry>
</elementAttributes>
<pos x="320" y="420"/>
</visualElement>
</visualElements>
<wires>
<wire>
<p1 x="300" y="340"/>
<p2 x="360" y="340"/>
</wire>
<wire>
<p1 x="300" y="300"/>
<p2 x="340" y="300"/>
</wire>
<wire>
<p1 x="380" y="300"/>
<p2 x="420" y="300"/>
</wire>
<wire>
<p1 x="360" y="320"/>
<p2 x="360" y="340"/>
</wire>
</wires>
</circuit>

0 comments on commit c53c522

Please sign in to comment.