LEFT | RIGHT |
(no file at all) | |
| 1 // Copyright 2011 The Go Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style |
| 3 // license that can be found in the LICENSE file. |
| 4 package main |
| 5 |
| 6 import ( |
| 7 "runtime" |
| 8 "testing" |
| 9 ) |
| 10 |
| 11 var ( |
| 12 thisOS = runtime.GOOS |
| 13 thisArch = runtime.GOARCH |
| 14 otherOS = "freebsd" |
| 15 otherArch = "arm" |
| 16 ) |
| 17 |
| 18 func init() { |
| 19 if thisOS == otherOS { |
| 20 otherOS = "linux" |
| 21 } |
| 22 if thisArch == otherArch { |
| 23 otherArch = "amd64" |
| 24 } |
| 25 } |
| 26 |
| 27 type GoodFileTest struct { |
| 28 name string |
| 29 result bool |
| 30 } |
| 31 |
| 32 var tests = []GoodFileTest{ |
| 33 {"file.go", true}, |
| 34 {"file.c", true}, |
| 35 {"file_foo.go", true}, |
| 36 {"file_" + thisArch + ".go", true}, |
| 37 {"file_" + otherArch + ".go", false}, |
| 38 {"file_" + thisOS + ".go", true}, |
| 39 {"file_" + otherOS + ".go", false}, |
| 40 {"file_" + thisOS + "_" + thisArch + ".go", true}, |
| 41 {"file_" + otherOS + "_" + thisArch + ".go", false}, |
| 42 {"file_" + thisOS + "_" + otherArch + ".go", false}, |
| 43 {"file_" + otherOS + "_" + otherArch + ".go", false}, |
| 44 {"file_foo_" + thisArch + ".go", true}, |
| 45 {"file_foo_" + otherArch + ".go", false}, |
| 46 {"file_" + thisOS + ".c", true}, |
| 47 {"file_" + otherOS + ".c", false}, |
| 48 } |
| 49 |
| 50 func TestGoodOSArch(t *testing.T) { |
| 51 for _, test := range tests { |
| 52 if goodOSArch(test.name) != test.result { |
| 53 t.Fatalf("goodOSArch(%q) != %v", test.name, test.result) |
| 54 } |
| 55 } |
| 56 } |
LEFT | RIGHT |