(t *testing.T)
| 221 | } |
| 222 | |
| 223 | func TestSetFromArgs(t *testing.T) { |
| 224 | cfg := &TestConfig{} |
| 225 | err := SetFromDefaults(cfg) |
| 226 | require.NoError(t, err) |
| 227 | // note: cannot use "-Includes=testcfg.toml", |
| 228 | args := []string{"-save-wts", "core", "-nogui", "-no-epoch-log", "--NoRunLog", "play", "--runs=5", "--run", "1", "--TAG", "nice", "--PatParams.Sparseness=0.1", "orange", "--Network", "{'.PFCLayer:Layer.Inhib.Gi' = '2.4', '#VSPatchProjection:Projection.Learn.LRate' = '0.01'}", "-Enum=TestValue2", "apple", "-Slice=3.2,2.4,1.9"} |
| 229 | |
| 230 | _, err = SetFromArgs(cfg, args, ErrNotFound) |
| 231 | require.NoError(t, err) |
| 232 | |
| 233 | if cfg.Runs != 5 || cfg.Run != 1 || cfg.Tag != "nice" || cfg.PatParams.Sparseness != 0.1 || cfg.SaveWts != true || cfg.GUI != false || cfg.EpochLog != false || cfg.RunLog != false { |
| 234 | t.Errorf("args not set properly (config: %#v)", cfg) |
| 235 | } |
| 236 | assert.Equal(t, testdata.TestValue2, cfg.Enum) |
| 237 | wcs := []float32{3.2, 2.4, 1.9} |
| 238 | assert.Equal(t, wcs, cfg.Slice) |
| 239 | wcss := []string{"core", "play", "orange", "apple"} |
| 240 | assert.Equal(t, wcss, cfg.StrSlice) |
| 241 | // if cfg.Network != nil { |
| 242 | // mv := cfg.Network |
| 243 | // for k, v := range mv { |
| 244 | // fmt.Println(k, " = ", v) |
| 245 | // } |
| 246 | // } |
| 247 | } |
| 248 | |
| 249 | // TestSetFromArgsErr ensures we get errors for various problems with arguments |
| 250 | func TestSetFromArgsErr(t *testing.T) { |
nothing calls this directly
no test coverage detected