-
Notifications
You must be signed in to change notification settings - Fork 973
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sharding/client: Adding tests and modifying utils(#92)
Former-commit-id: edbf5bd3d11b46f463bf26027178fb7d06fc13fb [formerly 73e4692] Former-commit-id: ca76a1e
- Loading branch information
nisdas
committed
May 16, 2018
1 parent
2026d42
commit 1df5683
Showing
2 changed files
with
75 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package client | ||
|
||
import ( | ||
"math/rand" | ||
"reflect" | ||
"runtime" | ||
"testing" | ||
) | ||
|
||
var testbody []interface{} | ||
|
||
func buildblob() []byte { | ||
|
||
tempbody := make([]byte, 500) | ||
for i := int64(0); i < 500; i++ { | ||
tempbody[i] = byte(rand.Int()) | ||
|
||
} | ||
|
||
return tempbody | ||
|
||
} | ||
func TestConvertInterface(t *testing.T) { | ||
var slice interface{} | ||
slice = []interface{}{0, 1, 2, 3, 4, 5} | ||
convertedValue, err := convertInterface(slice, reflect.Slice) | ||
if err != nil { | ||
t.Fatalf("Error: %v %v", err, convertedValue) | ||
} | ||
|
||
} | ||
|
||
func TestSerializeblob(t *testing.T) { | ||
|
||
blob := buildblob() | ||
|
||
serializedblob, err := serializeBlob(blob) | ||
|
||
if err != nil { | ||
t.Fatalf("Error Serializing blob:%v %v", err, serializedblob) | ||
} | ||
runtime.Breakpoint() | ||
err2 := Deserializebody(serializedblob, testbody) | ||
if err2 != nil { | ||
t.Fatalf("Error Serializing blob:%v", err2) | ||
} | ||
|
||
if !reflect.DeepEqual(blob, testbody) { | ||
|
||
t.Fatalf("Error Serializing blob with %v %v", blob, testbody) | ||
} | ||
|
||
} |