File tree Expand file tree Collapse file tree 2 files changed +53
-0
lines changed
Expand file tree Collapse file tree 2 files changed +53
-0
lines changed Original file line number Diff line number Diff line change 1+ (ns str-rep
2+ (:require [clojure.string :as str]))
3+
4+ (defn left-pad [s len pad]
5+ (concat (repeat (- len (count s)) pad) s))
6+
7+ (defn int->hex [i]
8+ (str/upper-case
9+ (Integer/toHexString i)))
10+
11+ (defn unicode-rep [char]
12+ (apply str " \\ u" (left-pad (int->hex (long char)) 4 \0 )))
13+
14+ (defn char-rep [char]
15+ (cond
16+ (= \backspace char)
17+ " \\ b"
18+ (= \tab char)
19+ " \\ t"
20+ (= \newline char)
21+ " \\ n"
22+ (= \formfeed char)
23+ " \\ f"
24+ (= \return char)
25+ " \\ r"
26+ (< (long char) 32 )
27+ (unicode-rep char)
28+ :else
29+ (str char)))
30+
31+ (defn str-rep [s]
32+ (str " \" "
33+ (apply str (map char-rep s))
34+ " \" " ))
Original file line number Diff line number Diff line change 1+ (ns lambdaisland.deep-diff2-test
2+ " Smoke tests of the top level API."
3+ (:require [lambdaisland.deep-diff2 :as ddiff]
4+ [lambdaisland.deep-diff2.diff-impl :as diff-impl]
5+ [clojure.test :refer [is are deftest testing]]
6+ [clojure.string :as str]))
7+
8+ (deftest diff-test
9+ (is (= [{:foo (diff-impl/->Mismatch 1 2 )}]
10+ (ddiff/diff [{:foo 1 }] [{:foo 2 }]))))
11+
12+ (deftest printer-test
13+ (is (instance? lambdaisland.deep_diff2.puget.printer.PrettyPrinter
14+ (ddiff/printer ))))
15+
16+ (deftest pretty-print-test
17+ (is (= " \u 001B[1;31m[\u 001B[0m\u 001B[1;31m{\u 001B[0m\u 001B[1;33m:foo\u 001B[0m \u 001B[31m-1\u 001B[0m \u 001B[32m+2\u 001B[0m\u 001B[1;31m}\u 001B[0m\u 001B[1;31m]\u 001B[0m\n "
18+ (with-out-str
19+ (ddiff/pretty-print (ddiff/diff [{:foo 1 }] [{:foo 2 }]))))))
You can’t perform that action at this time.
0 commit comments