-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Cristian G <cristian.castro@iohk.io>
- Loading branch information
1 parent
832bb62
commit 7653f88
Showing
2 changed files
with
44 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
...sdk/src/commonTest/kotlin/org/hyperledger/identus/walletsdk/pollux/utils/BitStringTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package org.hyperledger.identus.walletsdk.pollux.utils | ||
|
||
import org.junit.Assert.assertFalse | ||
import org.junit.Assert.assertTrue | ||
import org.junit.Test | ||
import java.util.* | ||
|
||
class BitStringTest { | ||
|
||
@Test | ||
fun `test BitString with some 0s`() { | ||
val byteArray = byteArrayOf(0.toByte()) | ||
val bitSet = BitSet.valueOf(byteArray) | ||
val bitString = BitString(bitSet, byteArray.size * 8) | ||
|
||
for (i in 0 until bitString.size) { | ||
assertFalse("Index $i should not be revoked", bitString.isRevoked(i)) | ||
} | ||
} | ||
|
||
@Test | ||
fun `test BitString with some 1s`() { | ||
val byteArray = byteArrayOf(128.toByte(), 1.toByte()) | ||
val bitSet = BitSet.valueOf(byteArray) | ||
val bitString = BitString(bitSet, byteArray.size * 8) | ||
|
||
assertTrue("Index 7 should be revoked", bitString.isRevoked(7)) | ||
assertTrue("Index 8 should be revoked", bitString.isRevoked(8)) | ||
for (i in 0 until 7) { | ||
assertFalse("Index $i should not be revoked", bitString.isRevoked(i)) | ||
} | ||
for (i in 9 until bitString.size) { | ||
assertFalse("Index $i should not be revoked", bitString.isRevoked(i)) | ||
} | ||
} | ||
|
||
} |