mirror of
https://github.com/maaslalani/slides.git
synced 2026-01-08 22:07:59 -05:00
65 lines
1.0 KiB
Go
65 lines
1.0 KiB
Go
package code
|
|
|
|
import "testing"
|
|
|
|
func TestHidesComments(t *testing.T) {
|
|
content := `
|
|
///package main
|
|
///
|
|
///import "fmt"
|
|
///
|
|
///func main() {
|
|
fmt.Println("Hello, world!")
|
|
///}`
|
|
|
|
expected := `
|
|
fmt.Println("Hello, world!")`
|
|
|
|
if HideComments(content) != expected {
|
|
t.Errorf("Expected %s, got %s", expected, HideComments(content))
|
|
}
|
|
}
|
|
|
|
func TestNoComments(t *testing.T) {
|
|
content := `
|
|
package main
|
|
|
|
import "fmt"
|
|
|
|
func main() {
|
|
fmt.Println("Hello, world!")
|
|
}`
|
|
expected := content
|
|
|
|
if HideComments(content) != expected {
|
|
t.Errorf("Expected %s, got %s", expected, HideComments(content))
|
|
}
|
|
if RemoveComments(content) != expected {
|
|
t.Errorf("Expected %s, got %s", expected, HideComments(content))
|
|
}
|
|
}
|
|
|
|
func TestRemoveComments(t *testing.T) {
|
|
content := `
|
|
///package main
|
|
///
|
|
///import "fmt"
|
|
///
|
|
///func main() {
|
|
fmt.Println("Hello, world!")
|
|
///}`
|
|
|
|
expected := `
|
|
package main
|
|
|
|
import "fmt"
|
|
|
|
func main() {
|
|
fmt.Println("Hello, world!")
|
|
}`
|
|
|
|
if RemoveComments(content) != expected {
|
|
t.Errorf("Expected %s, got %s", expected, RemoveComments(content))
|
|
}
|
|
}
|