From e5eb53adceaa5ba6e0a9e3e897e5b8dde053a703 Mon Sep 17 00:00:00 2001 From: webdevred <148627186+webdevred@users.noreply.github.com> Date: Sat, 18 Jul 2026 13:34:31 +0200 Subject: [PATCH] Add spec for newline detection --- test/Core/NewlineSpec.hs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 test/Core/NewlineSpec.hs diff --git a/test/Core/NewlineSpec.hs b/test/Core/NewlineSpec.hs new file mode 100644 index 00000000..59bb68fd --- /dev/null +++ b/test/Core/NewlineSpec.hs @@ -0,0 +1,17 @@ +module Core.NewlineSpec (spec) where + +import JbeamEdit.Core.Newline (detectNewline) +import System.IO (Newline (..)) +import Test.Hspec + +spec :: Spec +spec = + describe "detectNewline" $ do + it "detects LF for unix line endings" $ + detectNewline "a\nb\n" `shouldBe` LF + it "detects CRLF for windows line endings" $ + detectNewline "a\r\nb\r\n" `shouldBe` CRLF + it "detects CRLF when line endings are mixed" $ + detectNewline "a\r\nb\n" `shouldBe` CRLF + it "defaults to LF when there is no line ending" $ + detectNewline "abc" `shouldBe` LF