string_escaped.gravity 423 B

123456789101112131415161718192021222324
  1. #unittest {
  2. name: "String escaping cases.";
  3. error: NONE;
  4. result: true;
  5. };
  6. func main() {
  7. // hex escape
  8. var s1 = "Hello\x20World";
  9. var s2 = "Hello World";
  10. var b1 = (s1 == s2);
  11. // c-like escape
  12. var s3 = "Hello\tWorld";
  13. var s4 = "Hello World";
  14. var b2 = (s3 == s4);
  15. // UTF-8 4 characters escape
  16. var s5 = "Hello \U0001F601 World";
  17. var s6 = "Hello 😁 World";
  18. var b3 = (s5 == s6);
  19. return (b1 && b2 && b3)
  20. }