Skip to content

Commit

Permalink
Fix vectors bug
Browse files Browse the repository at this point in the history
  • Loading branch information
jgdavey committed May 23, 2017
1 parent 8c47995 commit 088faec
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
3 changes: 1 addition & 2 deletions src/doric/tabular.clj
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
[doric.protocols :refer :all]
[doric.formatting :refer [align-cell]]))


(defn calculate-width
([col rows]
(calculate-width col rows identity))
([{:keys [title name]} rows escape]
(->> rows
(map (comp escape str name))
(map (comp escape str #(get % name)))
(cons (escape title))
(map count)
(apply max))))
Expand Down
22 changes: 18 additions & 4 deletions test/doric/test/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,24 @@

;; TODO embiggen these tests
(deftest test-table
(let [rendered (table [{:1 3 :2 4}])]
(is (.contains rendered "| 1 | 2 |"))
(is (.contains rendered "| 3 | 4 |"))
(is (.contains rendered "|---+---|"))))
(let [rendered (table* [{:1 3 :2 4}])]
(is (= rendered
["|---+---|"
"| 1 | 2 |"
"|---+---|"
"| 3 | 4 |"
"|---+---|"]))))

(deftest test-render-vectors
(let [rendered (table* [[1 2] ["3" "4"] [:a :b]])]
(is (= rendered
["|----+----|"
"| 0 | 1 |"
"|----+----|"
"| 1 | 2 |"
"| 3 | 4 |"
"| :a | :b |"
"|----+----|"]))))

(deftest test-unicode-table
(let [rendered (table* {:format :unicode}
Expand Down

0 comments on commit 088faec

Please sign in to comment.