summaryrefslogtreecommitdiff
path: root/test/ConversionUtilsSpec.scala
blob: ec07cb0352d9bf2e2de0084e4cc8f7371d6b3b51 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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" in {
        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" in {
          hexStr2Bytes("123").toArray must equal(hexStr2Bytes("0123").toArray)
        }
      }
    }
  }

}