tag_test.go 902 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. package flags
  2. import (
  3. "testing"
  4. )
  5. func TestTagMissingColon(t *testing.T) {
  6. var opts = struct {
  7. Value bool `short`
  8. }{}
  9. assertParseFail(t, ErrTag, "expected `:' after key name, but got end of tag (in `short`)", &opts, "")
  10. }
  11. func TestTagMissingValue(t *testing.T) {
  12. var opts = struct {
  13. Value bool `short:`
  14. }{}
  15. assertParseFail(t, ErrTag, "expected `\"' to start tag value at end of tag (in `short:`)", &opts, "")
  16. }
  17. func TestTagMissingQuote(t *testing.T) {
  18. var opts = struct {
  19. Value bool `short:"v`
  20. }{}
  21. assertParseFail(t, ErrTag, "expected end of tag value `\"' at end of tag (in `short:\"v`)", &opts, "")
  22. }
  23. func TestTagNewline(t *testing.T) {
  24. var opts = struct {
  25. Value bool `long:"verbose" description:"verbose
  26. something"`
  27. }{}
  28. assertParseFail(t, ErrTag, "unexpected newline in tag value `description' (in `long:\"verbose\" description:\"verbose\nsomething\"`)", &opts, "")
  29. }