[GEMINI] Organize test suite to mirror new ctf.cli and ctf.forensics package structures

This commit is contained in:
venus
2026-07-19 03:46:26 -05:00
parent c61bfa11e5
commit 058b5c1eb5
6 changed files with 304 additions and 281 deletions

View File

@@ -0,0 +1,30 @@
# tests/forensics/test_parsers.py
# {{{ imports
from ctf.forensics import ParserFactory, JpegParser, PngParser, GifParser, FallbackParser
# }}}
# {{{ test_parser_factory_and_classes
def test_parser_factory_and_classes():
"""
Verifies that ParserFactory selects the correct parser subclass and
that individual FormatParser subclasses behave correctly.
"""
# Assert JPEG
jpeg_parser = ParserFactory.get_parser(b"\xff\xd8\xff\xe0\x00\x10JFIF")
assert isinstance(jpeg_parser, JpegParser)
# Assert PNG
png_parser = ParserFactory.get_parser(b"\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR")
assert isinstance(png_parser, PngParser)
# Assert GIF
gif_parser = ParserFactory.get_parser(b"GIF89a\x01\x00\x01\x00")
assert isinstance(gif_parser, GifParser)
# Assert Fallback
fallback_parser = ParserFactory.get_parser(b"MZ\x90\x00\x03\x00\x00\x00")
assert isinstance(fallback_parser, FallbackParser)
assert fallback_parser.parse_physical(b"") == {}
assert fallback_parser.get_comment(b"") == ""
assert fallback_parser.get_exif_tags(b"") == {}
# }}}