tunittest_light.nim 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import stdtest/unittest_light
  2. proc testAssertEquals() =
  3. assertEquals("foo", "foo")
  4. doAssertRaises(AssertionDefect):
  5. assertEquals("foo", "foo ")
  6. proc testMismatch() =
  7. assertEquals(1+1, 2*1)
  8. let a = """
  9. some test with space at the end of lines
  10. can be hard to spot differences when diffing in a terminal
  11. without this helper function
  12. """
  13. let b = """
  14. some test with space at the end of lines
  15. can be hard to spot differences when diffing in a terminal
  16. without this helper function
  17. """
  18. let output = mismatch(a, b)
  19. let expected = """
  20. lhs:{ some test with space at the end of lines \n
  21. \n
  22. can be hard to spot differences when diffing in a terminal \n
  23. without this helper function\n
  24. \n
  25. }
  26. rhs:{ some test with space at the end of lines \n
  27. \n
  28. can be hard to spot differences when diffing in a terminal \n
  29. without this helper function\n
  30. \n
  31. }
  32. lhs.len: 144 rhs.len: 143
  33. first mismatch index: 110
  34. lhs[i]: {" "}
  35. rhs[i]: {"\n"}
  36. lhs[0..<i]:{ some test with space at the end of lines \n
  37. \n
  38. can be hard to spot differences when diffing in a terminal }"""
  39. if output != expected:
  40. echo output
  41. doAssert false
  42. testMismatch()
  43. testAssertEquals()