(t *testing.T)
| 151 | } |
| 152 | |
| 153 | func TestConfigFunc(t *testing.T) { |
| 154 | cfg := &TestConfig{} |
| 155 | os.Args = []string{"myapp", "-no-net-data", "build", "-gpu", "../main", "-Note", "Hello, World", "-v", "-PAT_PARAMS_SPARSENESS=4"} |
| 156 | cmd, err := config(DefaultOptions("My App", "My App is an awesome app"), cfg, &Cmd[*TestConfig]{ |
| 157 | Func: func(tc *TestConfig) error { return nil }, |
| 158 | Name: "build", |
| 159 | Doc: "build builds stuff", |
| 160 | }) |
| 161 | if err != nil { |
| 162 | t.Fatal(err) |
| 163 | } |
| 164 | if cmd != "build" { |
| 165 | t.Errorf("expected command to be build but got %q", cmd) |
| 166 | } |
| 167 | if cfg.NetData || !cfg.GPU || cfg.Note != "Hello, World" || cfg.PatParams.Sparseness != 4 || !reflect.DeepEqual(cfg.StrSlice, []string{"../main"}) { |
| 168 | t.Errorf("error setting configuration info (config: %#v)", cfg) |
| 169 | } |
| 170 | if logx.UserLevel != slog.LevelInfo { |
| 171 | t.Errorf("expected logx user level to be info but it is %v", logx.UserLevel) |
| 172 | } |
| 173 | } |
| 174 | |
| 175 | func TestDefaults(t *testing.T) { |
| 176 | cfg := &TestConfig{} |
nothing calls this directly
no test coverage detected