Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Testing] Encode . decode test property #355

Open
dariodsa opened this issue Dec 27, 2020 · 0 comments
Open

[Testing] Encode . decode test property #355

dariodsa opened this issue Dec 27, 2020 · 0 comments
Labels
test Testing (unit, properties)

Comments

@dariodsa
Copy link
Collaborator

Encode . decode property-based testing is done on every data type in TOML, but there is an issue involving non-ascii characters (č, ž, щ, ё). The reason why that test fails for them is that those characters are converted into \Uxxxxxxxx and during the decode phase, they are not decoded back.
The solution to this problem can be resolved in two ways:

  1. change decoding phase to turn \Uxxxxxxxx into regular characters
  2. change equal function that will say that č is equal to \U0000010d

I am a fan of the second approach because semantically speaking those two characters should be equal.
I have already added some non-ascii characters to the test file, but I am not referring it to it anywhere in the code, as you can see down there.

genUnicodeChar = Gen.element
[ "č", "ć", "š", "đ", "ž", "Ö", "ё"
, "в", "ь", "ж", "ю", "ч", "ü", "я"
]
-- | Generates text from different symbols.
genText :: Gen Text
genText = genNotEscape $ fmap Text.concat $ Gen.list (Range.constant 0 256) $ Gen.choice
[ Text.singleton <$> Gen.alphaNum
, genEscapeSequence
, genPunctuation
, genUniHex4Color
, genUniHex8Color
--, genUnicodeChar
]

@dariodsa dariodsa added the test Testing (unit, properties) label Dec 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
test Testing (unit, properties)
Projects
None yet
Development

No branches or pull requests

1 participant