fixed a testing bug which causes two HighZ values to be not equal.

This commit is contained in:
hneemann 2016-08-22 15:21:31 +02:00
parent b92a96b15e
commit c53c522a71
4 changed files with 126 additions and 3 deletions

View File

@ -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;
@ -71,6 +88,9 @@ public class Value {
if (v.type != type) return false;
// both types are equal!
if (type == Type.HIGHZ) return true;
return value == v.value;
}

View File

@ -61,7 +61,7 @@ public class TestResultTest extends TestCase {
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"
@ -73,4 +73,16 @@ public class TestResultTest extends TestCase {
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());
}
}

View File

@ -24,9 +24,13 @@ public class TestTestableExamples extends TestCase {
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
*

View File

@ -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>