package hugolib import ( "fmt" "reflect" "regexp" "sort" "strings" "testing" "github.com/spf13/hugo/helpers" "github.com/spf13/hugo/tpl" "github.com/spf13/viper" ) func pageFromString(in, filename string) (*Page, error) { return NewPageFrom(strings.NewReader(in), filename) } func CheckShortCodeMatch(t *testing.T, input, expected string, template tpl.Template) { p, _ := pageFromString(SIMPLE_PAGE, "simple.md") output, err := HandleShortcodes(input, p, template) if err != nil { t.Fatalf("Shortcode rendered error %s. Expected: %q, Got: %q", err, expected, output) } if output != expected { t.Fatalf("Shortcode render didn't match. got %q but exxpected %q", output, expected) } } func TestShortcodeGoFuzzReports(t *testing.T) { tem := tpl.New() tem.AddInternalShortcode("sc.html", `foo`) p, _ := pageFromString(SIMPLE_PAGE, "simple.md") for i, this := range []struct { data string expectErr bool }{ {"{{}}", "Playing Video 47238zzb", tem) } func TestPositionalParamSC(t *testing.T) { tem := tpl.New() tem.AddInternalShortcode("video.html", `Playing Video {{ .Get 0 }}`) CheckShortCodeMatch(t, "{{< video 47238zzb >}}", "Playing Video 47238zzb", tem) CheckShortCodeMatch(t, "{{< video 47238zzb 132 >}}", "Playing Video 47238zzb", tem) CheckShortCodeMatch(t, "{{