(t *testing.T)
| 115 | func (cfg *TestConfig) IncludesPtr() *[]string { return &cfg.Includes } |
| 116 | |
| 117 | func TestRun(t *testing.T) { |
| 118 | cfg := &TestConfig{} |
| 119 | os.Args = []string{"myapp", "-gui", "install", "-no-gpu=f", "windows", "-Note", "Hello, World", "-PAT_PARAMS_SPARSENESS=4", "-net-data", "darwin"} |
| 120 | |
| 121 | // we test for correct config in and out of command through closure |
| 122 | var ( |
| 123 | inCmd bool |
| 124 | strSlice []string |
| 125 | gpu bool |
| 126 | sparseness float32 |
| 127 | ) |
| 128 | err := Run(DefaultOptions("My App", "My App is an awesome app"), cfg, &Cmd[*TestConfig]{ |
| 129 | Func: func(tc *TestConfig) error { |
| 130 | inCmd = true |
| 131 | strSlice = tc.StrSlice |
| 132 | gpu = tc.GPU |
| 133 | sparseness = tc.PatParams.Sparseness |
| 134 | if tc.Note != "Hello, World" { |
| 135 | t.Errorf("expeected note to be %q but got %q", "Hello, World", tc.Note) |
| 136 | } |
| 137 | return nil |
| 138 | }, |
| 139 | Name: "install", |
| 140 | Doc: "install installs stuff", |
| 141 | }) |
| 142 | if err != nil { |
| 143 | t.Error(err) |
| 144 | } |
| 145 | if !inCmd { |
| 146 | t.Errorf("never got into command") |
| 147 | } |
| 148 | if !reflect.DeepEqual(strSlice, []string{"windows", "darwin"}) || !gpu || sparseness != 4 { |
| 149 | t.Errorf("got bad values for config (config: %#v)", cfg) |
| 150 | } |
| 151 | } |
| 152 | |
| 153 | func TestConfigFunc(t *testing.T) { |
| 154 | cfg := &TestConfig{} |
nothing calls this directly
no test coverage detected