regexp_test.go 572 B

12345678910111213141516171819202122232425262728293031323334
  1. package regexp_test
  2. import (
  3. "fmt"
  4. "regexp"
  5. "testing"
  6. "github.com/issue9/assert"
  7. )
  8. func TestAll(t *testing.T) {
  9. fmt.Println("\ufffc")
  10. regxTest(t, ``)
  11. regxTest(t, `中文`)
  12. regxTest(t, "\\\\")
  13. regxTest(t, `\\u00ff`)
  14. regxTest(t, "\uffff")
  15. regxTest(t, "\u0100")
  16. for i := 0; i < 65536; i++ {
  17. // fmt.Println(fmt.Sprintf("%c", i))
  18. regxTest(t, fmt.Sprintf("%c", i))
  19. }
  20. fmt.Println()
  21. }
  22. func regxTest(t *testing.T, s string) {
  23. re, e := regexp.Compile(s)
  24. if re != nil {
  25. assert.True(t, re.MatchString(s))
  26. } else {
  27. fmt.Print(s, " ")
  28. }
  29. assert.Nil(t, e)
  30. }