You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

32 lines
679 B

  1. // Copyright 2013 The Go Authors. All rights reserved.
  2. //
  3. // Use of this source code is governed by a BSD-style
  4. // license that can be found in the LICENSE file or at
  5. // https://developers.google.com/open-source/licenses/bsd.
  6. package gosrc
  7. import (
  8. "testing"
  9. )
  10. var lineCommentTests = []struct {
  11. in, out string
  12. }{
  13. {"", ""},
  14. {"//line 1", "// "},
  15. {"//line x\n//line y", "// \n// "},
  16. {"x\n//line ", "x\n// "},
  17. }
  18. func TestOverwriteLineComments(t *testing.T) {
  19. for _, tt := range lineCommentTests {
  20. p := []byte(tt.in)
  21. OverwriteLineComments(p)
  22. s := string(p)
  23. if s != tt.out {
  24. t.Errorf("in=%q, actual=%q, expect=%q", tt.in, s, tt.out)
  25. }
  26. }
  27. }