1
0
Fork 0

Add unit test

Signed-off-by: Emile Vauge <emile@vauge.com>
This commit is contained in:
Emile Vauge 2016-04-20 13:26:51 +02:00
parent d82e1342fb
commit c0dd4c3209
No known key found for this signature in database
GPG key ID: D808B4C167352E59
8 changed files with 242 additions and 47 deletions

View file

@ -249,6 +249,19 @@ type IntOrString struct {
StrVal string
}
// FromInt creates an IntOrString object with an int32 value. It is
// your responsibility not to call this method with a value greater
// than int32.
// TODO: convert to (val int32)
func FromInt(val int) IntOrString {
return IntOrString{Type: Int, IntVal: int32(val)}
}
// FromString creates an IntOrString object with a string value.
func FromString(val string) IntOrString {
return IntOrString{Type: String, StrVal: val}
}
// String returns the string value, or the Itoa of the int value.
func (intstr *IntOrString) String() string {
if intstr.Type == String {