(t *testing.T)
| 12 | ) |
| 13 | |
| 14 | func TestBinaryContentType(t *testing.T) { |
| 15 | tests := []struct { |
| 16 | name string |
| 17 | content []byte |
| 18 | wantMIME string |
| 19 | wantBinary bool |
| 20 | }{ |
| 21 | { |
| 22 | name: "empty content is not binary", |
| 23 | content: []byte{}, |
| 24 | wantBinary: false, |
| 25 | }, |
| 26 | { |
| 27 | name: "plain text is not binary", |
| 28 | content: []byte("hello world\n"), |
| 29 | wantBinary: false, |
| 30 | }, |
| 31 | { |
| 32 | name: "png is binary", |
| 33 | content: append([]byte("\x89PNG\r\n\x1a\n"), make([]byte, 16)...), |
| 34 | wantMIME: "image/png", |
| 35 | wantBinary: true, |
| 36 | }, |
| 37 | } |
| 38 | |
| 39 | for _, tt := range tests { |
| 40 | t.Run(tt.name, func(t *testing.T) { |
| 41 | mime, ok := BinaryContentType(tt.content) |
| 42 | assert.Equal(t, tt.wantBinary, ok) |
| 43 | assert.Equal(t, tt.wantMIME, mime) |
| 44 | }) |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | func TestContainsEscapeSequence(t *testing.T) { |
| 49 | assert.False(t, ContainsEscapeSequence([]byte("plain text"))) |
nothing calls this directly
no test coverage detected