From a0de95a8033cabfb8151e99778932bb271bf6f6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rgen=20Brandt?= Date: Sun, 27 Dec 2015 10:56:14 +0100 Subject: [PATCH] Tests added. --- .../wbi/cuneiform/core/repl/BaseRepl.java | 2 +- .../core/semanticmodel/HashHelperTest.java | 60 +++++++++++++++++++ 2 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 cuneiform-core/src/test/java/de/huberlin/wbi/cuneiform/core/semanticmodel/HashHelperTest.java diff --git a/cuneiform-core/src/main/java/de/huberlin/wbi/cuneiform/core/repl/BaseRepl.java b/cuneiform-core/src/main/java/de/huberlin/wbi/cuneiform/core/repl/BaseRepl.java index 783ff29..eaae4d6 100644 --- a/cuneiform-core/src/main/java/de/huberlin/wbi/cuneiform/core/repl/BaseRepl.java +++ b/cuneiform-core/src/main/java/de/huberlin/wbi/cuneiform/core/repl/BaseRepl.java @@ -72,7 +72,7 @@ public abstract class BaseRepl { public static final int CTL_TICKETSET = 8; public static final String LABEL_VERSION = "2.0.2-SNAPSHOT"; - public static final String LABEL_BUILD = "2015-11-06"; + public static final String LABEL_BUILD = "2015-12-27"; private final CfSemanticModelVisitor state; private final Map runningMap; diff --git a/cuneiform-core/src/test/java/de/huberlin/wbi/cuneiform/core/semanticmodel/HashHelperTest.java b/cuneiform-core/src/test/java/de/huberlin/wbi/cuneiform/core/semanticmodel/HashHelperTest.java new file mode 100644 index 0000000..b8ad669 --- /dev/null +++ b/cuneiform-core/src/test/java/de/huberlin/wbi/cuneiform/core/semanticmodel/HashHelperTest.java @@ -0,0 +1,60 @@ +package de.huberlin.wbi.cuneiform.core.semanticmodel; + +import org.junit.Test; +import static org.junit.Assert.assertNotEquals; + +import java.util.UUID; + + +public class HashHelperTest { + + + @SuppressWarnings("static-method") + @Test + public void hashPreservesDifferencesBetweenStrings() { + + String a, b; + long h1, h2; + + a = "bla"; + b = "blub"; + + h1 = HashHelper.add( 0L, a ); + h2 = HashHelper.add( 0L, b ); + + assertNotEquals( h1, h2 ); + } + + @SuppressWarnings("static-method") + @Test + public void hashPreservesDifferencesBetweenTickets() { + + Ticket a, b; + long h1, h2; + UUID uuid; + ForeignLambdaExpr lambda1, lambda2; + Block bindingBlock; + Prototype prototype; + String lang; + String body1, body2; + + uuid = UUID.randomUUID(); + bindingBlock = new Block(); + + prototype = new Prototype(); + lang = ForeignLambdaExpr.LANGID_BASH; + body1 = "bla"; + body2 = "blub"; + + lambda1 = new ForeignLambdaExpr( prototype, lang, body1 ); + lambda2 = new ForeignLambdaExpr( prototype, lang, body2 ); + + a = new Ticket( lambda1, bindingBlock, uuid ); + b = new Ticket( lambda2, bindingBlock, uuid ); + + h1 = HashHelper.add( 0L, a ); + h2 = HashHelper.add( 0L, b ); + + assertNotEquals( h1, h2 ); + } +}