Skip to content

Commit

Permalink
test: ensure length result
Browse files Browse the repository at this point in the history
  • Loading branch information
joseluisq committed Oct 23, 2019
1 parent 468e601 commit 5954c40
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 9 deletions.
6 changes: 6 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"recommendations": [
"ms-vscode.go",
"vadimcn.vscode-lldb"
]
}
13 changes: 13 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceRoot}",
"args": []
}
]
}
32 changes: 23 additions & 9 deletions strand_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,30 @@ import (
"testing"
)

func TestRandomBytes(t *testing.T) {
func TestRandomBytess(t *testing.T) {
type args struct {
len int
}

tests := []struct {
name string
args args
want []byte
want int
wantErr bool
}{
// TODO: Add test cases
{
name: "Verify RandomBytes length result",
args: args{
len: 32,
},
want: 16,
},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := RandomBytes(tt.args.len)
res, err := RandomBytes(tt.args.len)
got := len(res)

if (err != nil) != tt.wantErr {
t.Errorf("RandomBytes() error = %v, wantErr %v", err, tt.wantErr)
Expand All @@ -43,23 +50,30 @@ func TestRandomString(t *testing.T) {
tests := []struct {
name string
args args
wantStr string
want int
wantErr bool
}{
// TODO: Add test cases
{
name: "Verify RandomString length result",
args: args{
len: 32,
},
want: 32,
},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
gotStr, err := RandomString(tt.args.len)
res, err := RandomString(tt.args.len)
gotStr := len(res)

if (err != nil) != tt.wantErr {
t.Errorf("RandomString() error = %v, wantErr %v", err, tt.wantErr)
return
}

if gotStr != tt.wantStr {
t.Errorf("RandomString() = %v, want %v", gotStr, tt.wantStr)
if gotStr != tt.want {
t.Errorf("RandomString() = %v, want %v", gotStr, tt.want)
}
})
}
Expand Down

0 comments on commit 5954c40

Please sign in to comment.