Add unit test
Signed-off-by: Emile Vauge <emile@vauge.com>
This commit is contained in:
parent
d82e1342fb
commit
c0dd4c3209
8 changed files with 242 additions and 47 deletions
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue