mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-26 22:41:59 -04:00
fixed a bug witch result in values always zero if 64 bit values are used.
This commit is contained in:
parent
4a6a8958fc
commit
a3a609178c
@ -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;
|
||||
}
|
||||
|
@ -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());
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user