bytearray_test.go 696 Bytes
Newer Older
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
/*!
 *  Copyright (c) 2018 by Contributors
 * \brief gotvm package
 * \file bytearray_test.go
 */


package gotvm

import (
    "testing"
    "math/rand"
)

// Check ByteArray creation from byte slice and verify the data.
func TestByteArrayGet(t *testing.T) {
    data := make([]byte, 1024)
    rand.Read(data)

    barr := newByteArray(data)
    dataRet := barr.getData()
    if len(data) != len(dataRet) {
            t.Errorf("Data expected Len: %v Got :%v\n", len(data), len(dataRet))
            return
    }
    for i := range data {
        if data[i] != dataRet[i] {
            t.Errorf("Data expected: %v Got :%v at : %v\n", data[i], dataRet[i], i)
            return
        }
    }
}