search_spec.lua 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. local helpers = require("test.unit.helpers")(after_each)
  2. local itp = helpers.gen_itp(it)
  3. local to_cstr = helpers.to_cstr
  4. local eq = helpers.eq
  5. local search = helpers.cimport("./src/nvim/search.h")
  6. itp('pat_has_uppercase', function()
  7. -- works on empty string
  8. eq(false, search.pat_has_uppercase(to_cstr("")))
  9. -- works with utf uppercase
  10. eq(false, search.pat_has_uppercase(to_cstr("ä")))
  11. eq(true, search.pat_has_uppercase(to_cstr("Ä")))
  12. eq(true, search.pat_has_uppercase(to_cstr("äaÅ")))
  13. -- works when pat ends with backslash
  14. eq(false, search.pat_has_uppercase(to_cstr("\\")))
  15. eq(false, search.pat_has_uppercase(to_cstr("ab$\\")))
  16. -- skips escaped characters
  17. eq(false, search.pat_has_uppercase(to_cstr("\\Ab")))
  18. eq(true, search.pat_has_uppercase(to_cstr("\\AU")))
  19. -- skips _X escaped characters
  20. eq(false, search.pat_has_uppercase(to_cstr("\\_Ab")))
  21. eq(true, search.pat_has_uppercase(to_cstr("\\_AU")))
  22. -- skips %X escaped characters
  23. eq(false, search.pat_has_uppercase(to_cstr("aa\\%Ab")))
  24. eq(true, search.pat_has_uppercase(to_cstr("aab\\%AU")))
  25. end)