Skip to content

Commit

Permalink
Add file-sniffer test that fails for bitstrings (#1393)
Browse files Browse the repository at this point in the history
  • Loading branch information
angelikatyborska authored Dec 9, 2023
1 parent 4dc3f9b commit a0e20d9
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions exercises/concept/file-sniffer/test/file_sniffer_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,35 @@ defmodule FileSnifferTest do
end
end

describe "return nil when input is a bitstring, but not a binary" do
@tag task_id: 2
test "bmp" do
assert FileSniffer.type_from_binary(<<0x42, 0x4D, 0::1>>) == nil
end

@tag task_id: 2
test "gif" do
assert FileSniffer.type_from_binary(<<0x47, 0x49, 0x46, 0::1>>) == nil
end

@tag task_id: 2
test "jpg" do
assert FileSniffer.type_from_binary(<<0xFF, 0xD8, 0xFF, 0::1>>) == nil
end

@tag task_id: 2
test "png" do
assert FileSniffer.type_from_binary(
<<0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A, 0::1>>
) == nil
end

@tag task_id: 2
test "exe" do
assert FileSniffer.type_from_binary(<<0x7F, 0x45, 0x4C, 0x46, 0::1>>) == nil
end
end

describe "verify valid files" do
@tag task_id: 3
test "bmp" do
Expand Down

0 comments on commit a0e20d9

Please sign in to comment.