context_test.go 419 B

1234567891011121314151617181920212223
  1. package llm
  2. import (
  3. "github.com/stretchr/testify/assert"
  4. "regexp"
  5. "testing"
  6. )
  7. func TestRegex(t *testing.T) {
  8. content := `
  9. server {
  10. listen 80;
  11. listen [::]:80;
  12. server_name _;
  13. include error_json;
  14. }
  15. `
  16. pattern := regexp.MustCompile(`(?m)^\s*include\s+([^;]+);`)
  17. matches := pattern.FindAllStringSubmatch(content, -1)
  18. assert.Equal(t, 1, len(matches))
  19. assert.Equal(t, "error_json", matches[0][1])
  20. }