diff options
author | iximeow <me@iximeow.net> | 2014-11-21 00:48:10 -0800 |
---|---|---|
committer | iximeow <me@iximeow.net> | 2014-11-21 00:48:10 -0800 |
commit | 708c0c523df97d1542b7b6d128c5218f6e2cc460 (patch) | |
tree | 7377685c7718a6028ee845614d902726422f1f1e /test | |
parent | 481bbd0ee786ec6056918fb2016244836e450907 (diff) |
Move things around a bit
Diffstat (limited to 'test')
-rw-r--r-- | test/ByteUtilsSpec.scala | 85 | ||||
-rw-r--r-- | test/ConversionUtilsSpec.scala | 31 |
2 files changed, 116 insertions, 0 deletions
diff --git a/test/ByteUtilsSpec.scala b/test/ByteUtilsSpec.scala new file mode 100644 index 0000000..8c7c7c9 --- /dev/null +++ b/test/ByteUtilsSpec.scala @@ -0,0 +1,85 @@ +package ixee.cryptopals.test + +import ixee.cryptopals.utils.ByteUtils + +import com.ixee.IxeeSpec + +class ByteUtilsSpec extends IxeeSpec { + + "ByteUtils" - { + + "SizedNumeric" - { + + ".liftedTo" - { + + "when the destination is >= the source in range" - { + + "losslessly converts to the destination type" - { + + } + + } + + "when the destination is smaller than the source" - { + + "throws an exception TODO: make it a Try?" - { + + } + + } + + } + + ".truncatedTo" - { + + "converts to the target type, truncating extra bytes" - { + + } + + } + + ".byteSize" - { + + "returns the size of a the type, in bytes" - { + + } + + } + + ".bitSize" - { + + "returns the size of a type, in bits" - { + + } + + } + + } + + "BitOps" - { + + "provides typed operations that don't upcast to Int" - { + + } + + } + + "toByteArray TODO: toByteSeq?" - { + + "returns the value as an array of bytes TODO: endianness?" - { + + } + + } + + "toBinaryString" - { + + "returns the value as a string of 1s and 0s, padded to the full size" - { + + } + + } + + } + +} diff --git a/test/ConversionUtilsSpec.scala b/test/ConversionUtilsSpec.scala new file mode 100644 index 0000000..d6c17b3 --- /dev/null +++ b/test/ConversionUtilsSpec.scala @@ -0,0 +1,31 @@ +package ixee.cryptopals.test + +import com.ixee.IxeeSpec +import org.scalatest._ + +class ConversionUtilsSpec extends FreeSpec with MustMatchers { + + import ixee.cryptopals.utils.ConversionUtils._ + + "ConversionUtils" - { + ".hexStr2Bytes" - { + "converts a hexadecimal string to an equivalent iterator of bytes" - { + hexStr2Bytes("12348765").toArray must equal( + Array[Byte]( + 0x12.toByte, + 0x34.toByte, + 0x87.toByte, + 0x65.toByte + ) + ) + } + + "when the string is not an even length" - { + "prepends a 0" - { + hexStr2Bytes("2123").toArray must equal(hexStr2Bytes("0123").toArray) + } + } + } + } + +} |