strings.nbt 869 B

12345678910111213141516171819202122232425262728
  1. assert_eq(str_length(""), 0)
  2. assert_eq(str_length("foo"), 3)
  3. assert_eq(str_slice(0, 5, "hello world"), "hello")
  4. assert_eq(str_slice(6, 11, "hello world"), "world")
  5. assert_eq(str_slice(0, 0, "hello world"), "")
  6. assert_eq(str_slice(0, 100, "hello world"), "")
  7. assert_eq(chr(65), "A")
  8. assert_eq(chr(97), "a")
  9. assert_eq(chr(0x2764), "❤")
  10. assert_eq(ord("A"), 65)
  11. assert_eq(ord("a"), 97)
  12. assert_eq(ord("❤"), 0x2764)
  13. assert_eq(str_append("foo", "bar"), "foobar")
  14. assert_eq(str_prepend("bar", "foo"), "foobar")
  15. assert(str_contains("hello", "hello world"))
  16. assert(str_contains("world", "hello world"))
  17. assert_eq(str_contains("HELLO", "hello world"), false)
  18. assert_eq(str_replace("hello", "HEY", "hello world"), "HEY world")
  19. assert_eq(str_replace("x", "yY", "xxx"), "yYyYyY")
  20. assert_eq(str_replace(" ", " ", "a b"), "a b")
  21. assert_eq(str_repeat(3, "xy"), "xyxyxy")