summaryrefslogtreecommitdiff
path: root/test/ConversionUtilsSpec.scala
blob: 74a5b89f9d3f86211dbac17a628974af185669c5 (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("2123").toArray must equal(hexStr2Bytes("0123").toArray)
        }
      }
    }
  }

}