@@ -4,51 +4,51 @@ import test
4
4
5
5
def main() = {
6
6
suite("Binstream", false){
7
- test("literal hex 10"){ assertEqual (x"10${()}", 16) }
8
- test("literal hex ff"){ assertEqual (x"ff${()}", 255) }
9
- test("literal char a"){ assertEqual (x"${'a'}", x"61${()}") }
10
- test("literal string ba"){ assertEqual (x"${"ba"}", x"62${()}" * 256 + x"61${()}") }
11
- test("int back-and-forth (17)"){ assertEqual (x"${17}", 17)}
12
- test("int back-and-forth (17), explicit BE"){ assertEqual (x"${17.BE}", 17) }
13
- test("int back-and-forth (17), explicit LE"){ assertEqual (x"${17.LE}", 17 * 256 * 256 * 256) }
7
+ test("literal hex 10"){ assert (x"10${()}", 16) }
8
+ test("literal hex ff"){ assert (x"ff${()}", 255) }
9
+ test("literal char a"){ assert (x"${'a'}", x"61${()}") }
10
+ test("literal string ba"){ assert (x"${"ba"}", x"62${()}" * 256 + x"61${()}") }
11
+ test("int back-and-forth (17)"){ assert (x"${17}", 17)}
12
+ test("int back-and-forth (17), explicit BE"){ assert (x"${17.BE}", 17) }
13
+ test("int back-and-forth (17), explicit LE"){ assert (x"${17.LE}", 17 * 256 * 256 * 256) }
14
14
test("byte 00101010"){
15
- with on[MissingValue].default{ assertEqual (true, false) }
16
- assertEqual (first[Byte]{groupBytes{ bit"00101010${()}" }}.toInt, 42)
15
+ with on[MissingValue].default{ assert (true, false) }
16
+ assert (first[Byte]{groupBytes{ bit"00101010${()}" }}.toInt, 42)
17
17
}
18
18
test("to bits and back"){
19
- with on[MissingValue].default{ assertEqual (true, false) }
19
+ with on[MissingValue].default{ assert (true, false) }
20
20
[42.toByte, 12.toByte, 113.toByte, 0.toByte, 255.toByte].foreach{ v =>
21
- assertEqual (first[Byte]{ groupBytes{ bits(v) } }, v)
21
+ assert (first[Byte]{ groupBytes{ bits(v) } }, v)
22
22
}
23
23
}
24
24
test("to bits and back LE bitorder"){
25
- with on[MissingValue].default{ assertEqual (true, false) }
25
+ with on[MissingValue].default{ assert (true, false) }
26
26
[42.toByte, 12.toByte, 113.toByte, 0.toByte, 255.toByte].foreach{ v =>
27
- assertEqual (first[Byte]{ groupBytesLE{ bitsLE(v) } }, v)
27
+ assert (first[Byte]{ groupBytesLE{ bitsLE(v) } }, v)
28
28
}
29
29
}
30
30
test("to bits and back BE bitorder"){
31
- with on[MissingValue].default{ assertEqual (true, false) }
31
+ with on[MissingValue].default{ assert (true, false) }
32
32
[42.toByte, 12.toByte, 113.toByte, 0.toByte, 255.toByte].foreach{ v =>
33
- assertEqual (first[Byte]{ groupBytesBE{ bitsBE(v) } }, v)
33
+ assert (first[Byte]{ groupBytesBE{ bitsBE(v) } }, v)
34
34
}
35
35
}
36
36
test("append 0 means *2"){
37
- with on[MissingValue].default{ assertEqual (true, false) }
37
+ with on[MissingValue].default{ assert (true, false) }
38
38
[42.toByte, 12.toByte, 127.toByte].foreach{ v =>
39
- assertEqual (nth[Byte](1){ groupBytes{ repeat(7){ do emit(B0()) }; bits(v); do emit(B0()) } }, (v.toInt * 2).toByte)
39
+ assert (nth[Byte](1){ groupBytes{ repeat(7){ do emit(B0()) }; bits(v); do emit(B0()) } }, (v.toInt * 2).toByte)
40
40
}
41
41
}
42
42
test("pow agrees with double one"){
43
- assertEqual (pow(2,5), pow(2.0,5).toInt)
43
+ assert (pow(2,5), pow(2.0,5).toInt)
44
44
}
45
45
test("LE 2s-complement"){
46
- with on[MissingValue].default{ assertEqual (true, false) }
47
- assertEqual (first[Byte]{ groupBytesLE{ twoscomplementLE{ bitsLE(6.toByte) } } }, 250.toByte)
46
+ with on[MissingValue].default{ assert (true, false) }
47
+ assert (first[Byte]{ groupBytesLE{ twoscomplementLE{ bitsLE(6.toByte) } } }, 250.toByte)
48
48
}
49
49
test("BE 2s-complement"){
50
- with on[MissingValue].default{ assertEqual (true, false) }
51
- assertEqual (first[Byte]{ groupBytesBE{ bit"${-6.Signed.BE.OfWidth(8)}" } }, 250.toByte)
50
+ with on[MissingValue].default{ assert (true, false) }
51
+ assert (first[Byte]{ groupBytesBE{ bit"${-6.Signed.BE.OfWidth(8)}" } }, 250.toByte)
52
52
}
53
53
}
54
54
()
0 commit comments