Setup test suite for encoding VLQs

This commit is contained in:
Robin Heggelund Hansen 2023-05-24 15:31:04 +02:00
parent f6853ededa
commit 56dc275d6f
No known key found for this signature in database
3 changed files with 28 additions and 0 deletions

View File

@ -0,0 +1,7 @@
module Generate.VLQ
( encode
) where
encode :: Int -> String
encode _num =
""

View File

@ -153,6 +153,7 @@ Common gren-common
Generate.JavaScript.Name
Generate.Mode
Generate.SourceMap
Generate.VLQ
Nitpick.Debug
Nitpick.PatternMatches
Optimize.Case
@ -255,6 +256,7 @@ Test-Suite gren-tests
Helpers.Parse
-- tests
Generate.VLQSpec
Integration.FormatSpec
Parse.AliasSpec
Parse.RecordUpdateSpec

19
tests/Generate/VLQSpec.hs Normal file
View File

@ -0,0 +1,19 @@
module Generate.VLQSpec (spec) where
import Generate.VLQ (encode)
import Test.Hspec (Spec, describe, it, shouldBe)
spec :: Spec
spec = do
describe "VLQ tests" $ do
it "Encodes from Int to String" $ do
encode 0 `shouldBe` "A"
encode 1 `shouldBe` "C"
encode (-1) `shouldBe` "D"
encode 3 `shouldBe` "G"
encode 123 `shouldBe` "2H"
encode 123456789 `shouldBe` "qxmvrH"
-- limits:
encode (-2147483648) `shouldBe` "B"
encode 2147483647 `shouldBe` "+/////D"