(t *testing.T)
| 966 | } |
| 967 | |
| 968 | func TestIsSingleImage(t *testing.T) { |
| 969 | const url = "https://example.invalid/probe" |
| 970 | |
| 971 | tests := []struct { |
| 972 | name string |
| 973 | markdown string |
| 974 | want bool |
| 975 | }{ |
| 976 | { |
| 977 | name: "one image pointing where it should", |
| 978 | markdown: "", |
| 979 | want: true, |
| 980 | }, |
| 981 | { |
| 982 | name: "empty alt text", |
| 983 | markdown: "", |
| 984 | want: true, |
| 985 | }, |
| 986 | { |
| 987 | name: "brackets that stay inside because they are escaped", |
| 988 | markdown: `![a \[bracketed\] caption](` + url + `)`, |
| 989 | want: true, |
| 990 | }, |
| 991 | { |
| 992 | name: "alt text that closes the image early takes the destination", |
| 993 | markdown: "](" + url + ")", |
| 994 | want: false, |
| 995 | }, |
| 996 | { |
| 997 | name: "alt text that adds a second image", |
| 998 | markdown: "", |
| 999 | want: false, |
| 1000 | }, |
| 1001 | { |
| 1002 | name: "alt text that leaves trailing prose outside the image", |
| 1003 | markdown: " and more", |
| 1004 | want: false, |
| 1005 | }, |
| 1006 | { |
| 1007 | name: "alt text that opens a second paragraph", |
| 1008 | markdown: "\n\nsecond", |
| 1009 | want: false, |
| 1010 | }, |
| 1011 | { |
| 1012 | name: "an image pointing somewhere else", |
| 1013 | markdown: "", |
| 1014 | want: false, |
| 1015 | }, |
| 1016 | { |
| 1017 | name: "no image at all", |
| 1018 | markdown: "just prose", |
| 1019 | want: false, |
| 1020 | }, |
| 1021 | { |
| 1022 | name: "nothing", |
| 1023 | markdown: "", |
| 1024 | want: false, |
| 1025 | }, |
nothing calls this directly
no test coverage detected