1-- SPDX-FileCopyrightText: 2026 Sören Tempel <soeren+git@soeren-tempel.net>2--3-- SPDX-License-Identifier: GPL-3.0-only45module Archive (archiveTests) where67import Data.Archive (Object (..))8import Test.Tasty9import Test.Tasty.HUnit10import Util (readArchive)1112archiveTests :: TestTree13archiveTests =14 testGroup15 "Test the parser for the ar(5) format"16 [ testCase "single file" $17 do18 objs <- readArchive "archive/single-file.ar"19 objs20 @?= [ Object21 { oName = "hello.txt/",22 oTime = 0,23 oUser = 0,24 oGroup = 0,25 oMode = 0o644,26 oSize = length "hello, world!\n",27 oData = "hello, world!\n"28 }29 ],30 testCase "single file with padding" $31 do32 objs <- readArchive "archive/single-file-with-padding.ar"33 case objs of34 [obj] -> oData obj @?= "12\n" -- padding removed35 _ -> assertFailure "unexpected object amount",36 testCase "multiple files" $37 do38 objs <- readArchive "archive/two-files-first-with-padding.ar"39 objs40 @?= [ Object41 { oName = "world.txt/",42 oTime = 0,43 oUser = 0,44 oGroup = 0,45 oMode = 0o644,46 oSize = length "world!\n",47 oData = "world!\n"48 },49 Object50 { oName = "hello.txt/",51 oTime = 0,52 oUser = 1000,53 oGroup = 1005,54 oMode = 0o644,55 oSize = length "hello\n",56 oData = "hello\n"57 }58 ],59 testCase "file name with space" $60 do61 objs <- readArchive "archive/file-name-containing-space.ar"62 case objs of63 -- See https://man.freebsd.org/cgi/man.cgi?query=ar&sektion=564 [obj] -> do65 oName obj @?= "A B"66 oData obj @?= "C D"67 _ -> assertFailure "unexpected object amount"68 ]