Browse Source

Tests: ASCII generator WIP

pull/6/head
heck 1 year ago
parent
commit
698e27c842
3 changed files with 22 additions and 10 deletions
  1. +1
    -1
      test/java/foundation/pEp/jniadapter/test/jni118/TestAlice.java
  2. +13
    -1
      test/java/foundation/pEp/jniadapter/test/jni143/TestAlice.java
  3. +8
    -8
      test/java/foundation/pEp/pitytest/utils/TestUtils.java

+ 1
- 1
test/java/foundation/pEp/jniadapter/test/jni118/TestAlice.java View File

@ -77,7 +77,7 @@ class TestAlice {
});
new TestUnit<JNI1118Context>("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);


+ 13
- 1
test/java/foundation/pEp/jniadapter/test/jni143/TestAlice.java View File

@ -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<CTXBase>("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();
}
}


+ 8
- 8
test/java/foundation/pEp/pitytest/utils/TestUtils.java View File

@ -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<Integer, CharClass> intMap;
private static HashMap<Integer, EASCIICharClassName> 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<Integer, CharClass>();
for (CharClass s : CharClass.values()) {
intMap = new HashMap<Integer, EASCIICharClassName>();
for (EASCIICharClassName s : EASCIICharClassName.values()) {
intMap.put(s.value, s);
}
}


Loading…
Cancel
Save