From 5b27bb40a7df469c0ca3ae09ae1ec93301fd264a Mon Sep 17 00:00:00 2001 From: hneemann Date: Wed, 5 Jul 2017 13:10:01 +0200 Subject: [PATCH] added a key translation consistence test --- .../de/neemann/digital/core/element/Key.java | 7 +++ src/main/resources/lang/lang_de.xml | 6 +++ src/main/resources/lang/lang_en.xml | 6 +++ .../digital/lang/TestKeyConsistence.java | 49 +++++++++++++++++++ 4 files changed, 68 insertions(+) create mode 100644 src/test/java/de/neemann/digital/lang/TestKeyConsistence.java diff --git a/src/main/java/de/neemann/digital/core/element/Key.java b/src/main/java/de/neemann/digital/core/element/Key.java index 7d431ab66..46953fdc5 100644 --- a/src/main/java/de/neemann/digital/core/element/Key.java +++ b/src/main/java/de/neemann/digital/core/element/Key.java @@ -75,6 +75,13 @@ public class Key { return getName(); } + /** + * @return the language key + */ + public String getLangKey() { + return langKey; + } + /** * A integer attribute. * Stores additional combo box values diff --git a/src/main/resources/lang/lang_de.xml b/src/main/resources/lang/lang_de.xml index 7d2a7781d..58446d382 100644 --- a/src/main/resources/lang/lang_de.xml +++ b/src/main/resources/lang/lang_de.xml @@ -574,6 +574,7 @@ Sind evtl. die Namen der Variablen nicht eindeutig? Größe Die Größe des Elements in der Schaltung. Sprache + Sprache der Oberfläche. Wird erst nach einem Neustart wirksam. Netzname Alle Netze mit identischem Namen werden miteinander verbunden. Eingangsaufteilung @@ -610,13 +611,18 @@ Sind evtl. die Namen der Variablen nicht eindeutig? Maximale Messpunktezahl Die maximale Anzahl an Messpunkten die gespeichert werden, bevor die ältesten Messungen verworfen werden. Zeige Einzelgatterschritte + Zeigt in der Grafik alle Einzelgatterschritte an. Rotation Legt die Ausrichtung des Elementes in der Schaltung fest. Echtzeittakt starten Wenn eingeschaltet, wird beim Start der Schaltung der Echtzeittakt gestartet. Zeige Messwertegraph + Beim Start der Simulation wird ein Graph mit den Messwerten angezeigt. Zeige Messwertgraph im Gatterschrittmodus + Beim Start der Simulation wird ein Graph mit den Messwerten im Gatterschrittmodus + angezeigt. Dabei werden alle Gatterwechsel angezeigt. Zeige Messwertetabelle + Beim Start der Simulation wird eine Tabelle mit den Messwerten angezeigt. Zeige Listing an, wenn verfügbar Zeilen Die Anzahl der anzuzeigenden Zeilen. diff --git a/src/main/resources/lang/lang_en.xml b/src/main/resources/lang/lang_en.xml index 2163ba602..f4394efc2 100644 --- a/src/main/resources/lang/lang_en.xml +++ b/src/main/resources/lang/lang_en.xml @@ -564,6 +564,7 @@ The names of the variables may not be unique. Size The size of the component in the circuit. Language + Language of the GUI. Will only take effect after a restart. Net name All nets with identical name are connected together. Input Splitting @@ -600,13 +601,18 @@ The names of the variables may not be unique. Max number of steps to show The maximal number of values stored. If the maximum number is reached, the oldest values are discarded. Show single gate steps + Shows all single step steps in the graphic. Rotation The orientation of the Element in the circuit. Start real time clock If enabled the runtime clock is started when the circuit is started Show measurement graph + When the simulation is started, a graph with the measured values is shown. Show measurement graph in single gate step mode + When the simulation is started, a graph with the measured values in the + gate step mode is shown. All gate changes are included in the graph. Show measurement values + When the simulation is started, a table with the measured values is shown. Show list file if available Lines The number of lines to show. diff --git a/src/test/java/de/neemann/digital/lang/TestKeyConsistence.java b/src/test/java/de/neemann/digital/lang/TestKeyConsistence.java new file mode 100644 index 000000000..a3adb7ccd --- /dev/null +++ b/src/test/java/de/neemann/digital/lang/TestKeyConsistence.java @@ -0,0 +1,49 @@ +package de.neemann.digital.lang; + +import de.neemann.digital.core.NodeException; +import de.neemann.digital.core.basic.FanIn; +import de.neemann.digital.core.element.*; +import de.neemann.digital.core.memory.LookUpTable; +import de.neemann.digital.core.wiring.Decoder; +import de.neemann.digital.core.wiring.Demultiplexer; +import de.neemann.digital.core.wiring.Splitter; +import de.neemann.digital.draw.elements.PinException; +import de.neemann.digital.draw.graphics.GraphicSVG; +import de.neemann.digital.draw.library.ElementLibrary; +import junit.framework.TestCase; + +import java.lang.reflect.Field; + +/** + * Created by hneemann on 19.11.16. + */ +public class TestKeyConsistence extends TestCase { + + /** + * Checks if key descriptions are complete + * + * @throws NodeException + * @throws PinException + * @throws IllegalAccessException + */ + public void testConsistence() throws NodeException, PinException, IllegalAccessException { + for (Field f : Keys.class.getDeclaredFields()) { + Key key = ((Key) f.get(null)); + checkKey(key.getLangKey()); + checkKey(key.getLangKey() + "_tt"); + } + } + + private void checkKey(String key) { + String str = Lang.getNull(key); + if (str == null) + missing(key); + } + + private void missing(String key) { + final String xml = GraphicSVG.escapeXML(key); + System.out.println("" + xml + ""); + fail("key '" + key + "' is missing!"); + } + +}