more consistent string conversion of high-z values, see #511

This commit is contained in:
hneemann 2020-09-12 10:51:51 +02:00
parent 7c2d944856
commit a526c91bc9
4 changed files with 5 additions and 5 deletions

View File

@ -66,7 +66,7 @@ public enum IntFormat {
*/
public String formatToEdit(Value inValue) {
if (inValue.isHighZ())
return "?";
return "Z";
switch (this) {
case dec:

View File

@ -49,7 +49,7 @@ public class InValue {
* @throws Bits.NumberFormatException NumberFormatException
*/
public InValue(String value) throws Bits.NumberFormatException {
if (value.toLowerCase().trim().equalsIgnoreCase("z")) {
if (value.trim().equalsIgnoreCase("z")) {
this.highZ = true;
this.value = 0;
} else {

View File

@ -236,7 +236,7 @@ public final class SingleValueDialog extends JDialog implements ModelStateObserv
textField.setText("0" + Long.toOctalString(editValue));
break;
case HIGHZ:
textField.setText("?");
textField.setText("Z");
break;
default:
}
@ -267,7 +267,7 @@ public final class SingleValueDialog extends JDialog implements ModelStateObserv
private void setStringToDialog(String text) {
text = text.trim();
if (text.length() > 0) {
if (text.contains("?") && supportsHighZ) {
if (text.contains("Z") && supportsHighZ) {
setSelectedFormat(InMode.HIGHZ);
editValue = 0;
} else if (text.charAt(0) == '\'') {

View File

@ -20,6 +20,6 @@ public class ValueTest extends TestCase {
public void testFromInValue() throws Bits.NumberFormatException {
assertEquals("5", new Value(new InValue("5"), 4).toString());
assertEquals("Z", new Value(new InValue("z"), 4).toString());
assertEquals("?", IntFormat.hex.formatToEdit(new Value(new InValue("z"), 4)));
assertEquals("Z", IntFormat.hex.formatToEdit(new Value(new InValue("z"), 4)));
}
}