haf / expecto

A smooth testing lib for F#. APIs made for humans! Strong testing methodologies for everyone!
Apache License 2.0
663 stars 96 forks source link

Expecto.Diff doesn't handle unicode characters. #418

Closed MNie closed 3 years ago

MNie commented 3 years ago

It seems that Expecto.Diff doesn't handle Unicode characters properly.

Following code snippet:

let tests = testList "Something" [
    testCase "blah blah" <| fun _ ->
      let input = "C:\\пользователи\\общественности\\кафедра"
      let user = "dobromir"

      let result = action input user

      Expect.equal result "C:\\польdsfsdfdsзователи\\dobromir\\кафедра" ""
  ]

[<EntryPoint>]
let main args =
  Expecto.Expect.defaultDiffPrinter <- Expecto.Diff.colourisedDiff
  runTestsWithCLIArgs [] args tests

Produces the following error message:

image

Whereas the expected output is C:\\пользователи\\dobromir\\кафедра

Invalid check in Expect.equal is: C:\\польdsfsdfdsзователи\\dobromir\\кафедра

Outlined part should be: dsfsdfds

MNie commented 3 years ago

It seems to be a problem with console/PowerShell itself. Need to run following command in Powershell:

$OutputEncoding = [console]::InputEncoding = [console]::OutputEncoding =
                    New-Object System.Text.UTF8Encoding