From 698e27c842dc9732db32f93ccb5baf3c7260490a Mon Sep 17 00:00:00 2001 From: heck Date: Tue, 30 Mar 2021 01:06:06 +0200 Subject: [PATCH] Tests: ASCII generator WIP --- .../pEp/jniadapter/test/jni118/TestAlice.java | 2 +- .../pEp/jniadapter/test/jni143/TestAlice.java | 14 +++++++++++++- .../foundation/pEp/pitytest/utils/TestUtils.java | 16 ++++++++-------- 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/test/java/foundation/pEp/jniadapter/test/jni118/TestAlice.java b/test/java/foundation/pEp/jniadapter/test/jni118/TestAlice.java index 609cbaf..086ee53 100644 --- a/test/java/foundation/pEp/jniadapter/test/jni118/TestAlice.java +++ b/test/java/foundation/pEp/jniadapter/test/jni118/TestAlice.java @@ -77,7 +77,7 @@ class TestAlice { }); new TestUnit("re_evaluate_message_rating() equal to decrypt_message_result.rating when Message has random rating string on XEncStatus", new JNI1118Context(), ctx -> { - AdapterTestUtils.addRatingToOptFields(ctx.msgToBobDecrypted, TestUtils.randomASCIIString(TestUtils.CharClass.All, TestUtils.randomInt(new RangeInt(0,42)))); + AdapterTestUtils.addRatingToOptFields(ctx.msgToBobDecrypted, TestUtils.randomASCIIString(TestUtils.EASCIICharClassName.All, TestUtils.randomInt(new RangeInt(0,42)))); AdapterTestUtils.addRcptsToOptFields(ctx.msgToBobDecrypted,Identity.toXKeyList(ctx.msgToBobDecrypted.getTo())); log("running re_evaluate_message_rating() on:\n" + AdapterTestUtils.msgToString(ctx.msgToBobDecrypted, false)); Rating rat = ctx.engine.re_evaluate_message_rating(ctx.msgToBobDecrypted); diff --git a/test/java/foundation/pEp/jniadapter/test/jni143/TestAlice.java b/test/java/foundation/pEp/jniadapter/test/jni143/TestAlice.java index 2b90555..66e3cce 100644 --- a/test/java/foundation/pEp/jniadapter/test/jni143/TestAlice.java +++ b/test/java/foundation/pEp/jniadapter/test/jni143/TestAlice.java @@ -5,8 +5,11 @@ import foundation.pEp.jniadapter.Message; import foundation.pEp.jniadapter.decrypt_message_Return; import foundation.pEp.jniadapter.test.utils.AdapterTestUtils; import foundation.pEp.jniadapter.test.utils.CTXBase; +import foundation.pEp.pitytest.StopWatch; import foundation.pEp.pitytest.TestSuite; import foundation.pEp.pitytest.TestUnit; +import foundation.pEp.pitytest.utils.SlowFilteredNoise; +import foundation.pEp.pitytest.utils.RangeInt; import foundation.pEp.pitytest.utils.TestUtils; import java.util.Arrays; @@ -73,9 +76,18 @@ class TestAlice { attachmentSizeBytes *= 2; } + }).run(); + + // TODO: + new TestUnit("Attachement sizes", new CTXBase(), ctx -> { + SlowFilteredNoise sfn = new SlowFilteredNoise(); + sfn.addSelection(new RangeInt(0,10)); + sfn.addSelection(new RangeInt(50,100)); + sfn.addFilter(new RangeInt(60,89)); + log(sfn.toString()); }); - TestSuite.getDefault().run(); +// TestSuite.getDefault().run(); } } diff --git a/test/java/foundation/pEp/pitytest/utils/TestUtils.java b/test/java/foundation/pEp/pitytest/utils/TestUtils.java index 30d902e..e8132d7 100644 --- a/test/java/foundation/pEp/pitytest/utils/TestUtils.java +++ b/test/java/foundation/pEp/pitytest/utils/TestUtils.java @@ -340,7 +340,7 @@ public class TestUtils { } - public static String randomASCIIString(CharClass charClass, int len) { + public static String randomASCIIString(EASCIICharClassName charClass, int len) { byte[] array = new byte[len]; // length is bounded by 7 int rangeMin = 0; int rangeMax = 0; @@ -375,11 +375,11 @@ public class TestUtils { return generatedString; } - public enum CharClass { + public enum EASCIICharClassName { All(0) { @Override public String toString() { - return "Unbounded"; + return "All"; } }, Alpha(1) { @@ -403,16 +403,16 @@ public class TestUtils { public final int value; - private static HashMap intMap; + private static HashMap intMap; - private CharClass(int value) { + private EASCIICharClassName(int value) { this.value = value; } - public static CharClass getByInt(int value) { + public static EASCIICharClassName getByInt(int value) { if (intMap == null) { - intMap = new HashMap(); - for (CharClass s : CharClass.values()) { + intMap = new HashMap(); + for (EASCIICharClassName s : EASCIICharClassName.values()) { intMap.put(s.value, s); } }