funcool/cuerdas

Prune is not truncating at the expected position

nberger opened this issue · 5 comments

I think cuerdas.core/prune is not truncating at the correct place. I'll show in the form of examples for clojure.test, using the ns aliases form cuerdas.core-tests:

(t/testing "prune"
  (t/is (= nil (str/prune nil 8)))
  (t/is (= "Hello..." (str/prune "Hello World" 8)))
  (t/is (= "Hello (...)"
           (str/prune "Hello World" 10 " (...)")))
  (t/is (= "Hello World"
           (str/prune "Hello World" 11 " (...)")))
  (t/is (= "Hello World, I'm pruning..."
           (str/prune "Hello World, I'm pruning strings today!" 25))))

The result of running the tests;

FAIL in (cuerdas-tests) (core_tests.cljc:150)
prune
expected: "Hello World"
  actual: "Hello (...)"
    diff: - "Hello World"
          + "Hello (...)"

FAIL in (cuerdas-tests) (core_tests.cljc:152)
prune
expected: "Hello World, I'm pruning..."
  actual: "Hello World, I'm pruning strings today!"
    diff: - "Hello World, I'm pruning..."
          + "Hello World, I'm pruning strings today!"

I might be missing something, but those are some examples of what I expect from prune

Thanks!, now fixed in master.

Cool, thanks to you!

0.7.1 version just released!

Awesome!