summaryrefslogtreecommitdiff
path: root/test/ConversionUtilsSpec.scala
blob: d6c17b369d1eec7ca5f22a7774f2a9187d81de9d (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" - {
        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)
        }
      }
    }
  }

}