strings.nbt 822 B

123456789101112131415161718192021222324252627
  1. assert_eq(str_length(""), 0)
  2. assert_eq(str_length("foo"), 3)
  3. assert_eq(str_slice("hello world", 0, 5), "hello")
  4. assert_eq(str_slice("hello world", 6, 11), "world")
  5. assert_eq(str_slice("hello world", 0, 0), "")
  6. assert_eq(str_slice("hello world", 0, 100), "")
  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(str_contains("hello world", "hello"))
  15. assert(str_contains("hello world", "world"))
  16. assert_eq(str_contains("hello world", "HELLO"), false)
  17. assert_eq(str_replace("hello world", "hello", "HEY"), "HEY world")
  18. assert_eq(str_replace("xxx", "x", "yY"), "yYyYyY")
  19. assert_eq(str_replace("a b", " ", " "), "a b")
  20. assert_eq(str_repeat("xy", 3), "xyxyxy")