Merge remote-tracking branch 'origin/dao-permute-blindvotelist-if-not-majority-hash' into dao-permute-blindvotelist-if-not-majority-hash

This commit is contained in:
Manfred Karrer 2019-02-03 21:02:31 +01:00
commit 7a6cce615a
No known key found for this signature in database
GPG Key ID: 401250966A6B2C46
2 changed files with 8 additions and 8 deletions

View File

@ -60,7 +60,7 @@ public class PermutationUtil {
* With 20 items we reach about 1 million iterations and it takes about 0.5 sec.
* To avoid performance issues we added the maxIterations parameter to stop once the number of iterations has
* reached the maxIterations and return in such a case the list of permutations we have been able to create.
* Depending on the type of object which is stored in the list the memory usage should to be considered as well for
* Depending on the type of object which is stored in the list the memory usage should be considered as well for
* choosing the right maxIterations value.
*
* @param list List from which we create permutations

View File

@ -51,7 +51,7 @@ public class PermutationTest {
assertTrue(expected.toString().equals(result.toString()));
// remove first
indicesToRemove = indicesToRemove = Collections.singletonList(0);
indicesToRemove = Collections.singletonList(0);
expected = new ArrayList<>(list);
expected.remove(0);
result = PermutationUtil.getPartialList(list, indicesToRemove);
@ -65,31 +65,31 @@ public class PermutationTest {
assertTrue(expected.toString().equals(result.toString()));
// remove all
indicesToRemove = indicesToRemove = Arrays.asList(0, 1, 2, 3, 4, 5);
indicesToRemove = Arrays.asList(0, 1, 2, 3, 4, 5);
expected = new ArrayList<>();
result = PermutationUtil.getPartialList(list, indicesToRemove);
assertTrue(expected.toString().equals(result.toString()));
// wrong sorting of indices
indicesToRemove = indicesToRemove = Arrays.asList(4, 0, 1);
indicesToRemove = Arrays.asList(4, 0, 1);
expected = expected = new ArrayList<>(Arrays.asList(blindVote2, blindVote3, blindVote5));
result = PermutationUtil.getPartialList(list, indicesToRemove);
assertTrue(expected.toString().equals(result.toString()));
// wrong sorting of indices
indicesToRemove = indicesToRemove = Arrays.asList(0, 0);
expected = expected = new ArrayList<>(Arrays.asList(blindVote1, blindVote2, blindVote3, blindVote4, blindVote5));
indicesToRemove = Arrays.asList(0, 0);
expected = new ArrayList<>(Arrays.asList(blindVote1, blindVote2, blindVote3, blindVote4, blindVote5));
result = PermutationUtil.getPartialList(list, indicesToRemove);
assertTrue(expected.toString().equals(result.toString()));
// don't remove as invalid index
indicesToRemove = indicesToRemove = Collections.singletonList(9);
indicesToRemove = Collections.singletonList(9);
expected = new ArrayList<>(list);
result = PermutationUtil.getPartialList(list, indicesToRemove);
assertTrue(expected.toString().equals(result.toString()));
// don't remove as invalid index
indicesToRemove = indicesToRemove = Collections.singletonList(-2);
indicesToRemove = Collections.singletonList(-2);
expected = new ArrayList<>(list);
result = PermutationUtil.getPartialList(list, indicesToRemove);
assertTrue(expected.toString().equals(result.toString()));