Created
December 2, 2018 08:36
-
-
Save laynax/3e8dfba6bfc2defddf1f32209aeaa85a to your computer and use it in GitHub Desktop.
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
package main | |
import ( | |
"encoding/json" | |
"testing" | |
) | |
type Card struct { | |
Card string | |
Pin int | |
Cvv2 int | |
} | |
var input1 = `{ | |
"card": "60379972576170363", | |
"pin": 123456, | |
"cvv2": 123 | |
}` | |
var input2 = `{ | |
"card": "60379972576170363", | |
"cvv2": 123 | |
}` | |
func TestInpu1(t *testing.T) { | |
var val Card | |
if err := json.Unmarshal([]byte(input1), &val); err != nil { | |
t.Error(err.Error()) | |
} | |
if val.Pin == 0 { | |
t.Error("pin could not be empty") | |
} | |
} | |
func TestInput2(t *testing.T) { | |
var val Card | |
if err := json.Unmarshal([]byte(input2), &val); err != nil { | |
t.Error(err.Error()) | |
} | |
if val.Pin == 0 { | |
t.Error("pin could not be empty") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment