fixed a bug witch result in values always zero if 64 bit values are used.

This commit is contained in:
hneemann 2017-03-04 17:29:12 +01:00
parent 4a6a8958fc
commit a3a609178c
2 changed files with 32 additions and 1 deletions

View File

@ -39,7 +39,10 @@ public class ObservableValue extends Observable implements PinDescription {
super();
this.bits = bits;
this.highZ = highZ;
mask = (1L << bits) - 1;
if (bits > 63)
mask = -1;
else
mask = (1L << bits) - 1;
this.name = name;
supportsHighZ = highZ;
}

View File

@ -0,0 +1,28 @@
package de.neemann.digital.core;
import junit.framework.TestCase;
/**
* Created by hneemann on 04.03.17.
*/
public class ObservableValueTest extends TestCase {
public void testSetValue1() throws Exception {
ObservableValue v = new ObservableValue("z", 64);
v.setValue(5);
assertEquals(5, v.getValue());
}
public void testSetValue2() throws Exception {
ObservableValue v = new ObservableValue("z", 63);
v.setValue(-1);
assertEquals((1l << 63) - 1, v.getValue());
}
public void testSetValue3() throws Exception {
ObservableValue v = new ObservableValue("z", 62);
v.setValue(-1);
assertEquals((1l << 62) - 1, v.getValue());
}
}