2013-07-30 19:05:20 -04:00
|
|
|
package main
|
2013-08-12 02:12:20 -04:00
|
|
|
|
|
|
|
import (
|
|
|
|
"reflect"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestExtractMachineReadable(t *testing.T) {
|
|
|
|
var args, expected, result []string
|
|
|
|
var mr bool
|
|
|
|
|
|
|
|
// Not
|
|
|
|
args = []string{"foo", "bar", "baz"}
|
|
|
|
result, mr = extractMachineReadable(args)
|
|
|
|
expected = []string{"foo", "bar", "baz"}
|
|
|
|
if !reflect.DeepEqual(result, expected) {
|
|
|
|
t.Fatalf("bad: %#v", result)
|
|
|
|
}
|
|
|
|
|
|
|
|
if mr {
|
|
|
|
t.Fatal("should not be mr")
|
|
|
|
}
|
|
|
|
|
|
|
|
// Yes
|
2013-08-12 12:19:24 -04:00
|
|
|
args = []string{"foo", "-machine-readable", "baz"}
|
2013-08-12 02:12:20 -04:00
|
|
|
result, mr = extractMachineReadable(args)
|
|
|
|
expected = []string{"foo", "baz"}
|
|
|
|
if !reflect.DeepEqual(result, expected) {
|
|
|
|
t.Fatalf("bad: %#v", result)
|
|
|
|
}
|
|
|
|
|
|
|
|
if !mr {
|
|
|
|
t.Fatal("should be mr")
|
|
|
|
}
|
|
|
|
}
|