common_test.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT.
  2. package idna
  3. // This file contains code that is common between the generation code and the
  4. // package's test code.
  5. import (
  6. "log"
  7. "golang.org/x/text/internal/ucd"
  8. )
  9. func catFromEntry(p *ucd.Parser) (cat category) {
  10. r := p.Rune(0)
  11. switch s := p.String(1); s {
  12. case "valid":
  13. cat = valid
  14. case "disallowed":
  15. cat = disallowed
  16. case "disallowed_STD3_valid":
  17. cat = disallowedSTD3Valid
  18. case "disallowed_STD3_mapped":
  19. cat = disallowedSTD3Mapped
  20. case "mapped":
  21. cat = mapped
  22. case "deviation":
  23. cat = deviation
  24. case "ignored":
  25. cat = ignored
  26. default:
  27. log.Fatalf("%U: Unknown category %q", r, s)
  28. }
  29. if s := p.String(3); s != "" {
  30. if cat != valid {
  31. log.Fatalf(`%U: %s defined for %q; want "valid"`, r, s, p.String(1))
  32. }
  33. switch s {
  34. case "NV8":
  35. cat = validNV8
  36. case "XV8":
  37. cat = validXV8
  38. default:
  39. log.Fatalf("%U: Unexpected exception %q", r, s)
  40. }
  41. }
  42. return cat
  43. }
  44. var joinType = map[string]info{
  45. "L": joiningL,
  46. "D": joiningD,
  47. "T": joiningT,
  48. "R": joiningR,
  49. }