-
-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathconvert_test.go
More file actions
34 lines (25 loc) · 705 Bytes
/
convert_test.go
File metadata and controls
34 lines (25 loc) · 705 Bytes
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
32
33
34
// Copyright (c) Roman Atachiants and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for details.
package binary
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestConvert_String(t *testing.T) {
v := "hi there"
b := ToBytes(v)
assert.NotEmpty(t, b)
assert.Equal(t, v, string(b))
o := ToString(&b)
assert.NotEmpty(t, b)
assert.Equal(t, v, o)
}
func TestConvert_Bools(t *testing.T) {
v := []bool{true, false, true, true, false, false}
b := boolsToBinary(&v)
assert.NotEmpty(t, b)
assert.Equal(t, []byte{0x1, 0x0, 0x1, 0x1, 0x0, 0x0}, b)
o := binaryToBools(&b)
assert.NotEmpty(t, b)
assert.Equal(t, v, o)
}