From 25b84f6488f233df1f2e58fb8d4f05af4e03c6be Mon Sep 17 00:00:00 2001 From: Peter Taoussanis Date: Tue, 5 Feb 2013 20:41:26 +0700 Subject: [PATCH] Add Snappy library compatibility tests --- project.clj | 2 +- test/test_nippy/main.clj | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/project.clj b/project.clj index 2175f99..6e88198 100644 --- a/project.clj +++ b/project.clj @@ -8,7 +8,7 @@ :1.4 {:dependencies [[org.clojure/clojure "1.4.0"]]} :1.5 {:dependencies [[org.clojure/clojure "1.5.0-alpha3"]]} :dev {:dependencies []} - :test {:dependencies []}} + :test {:dependencies [[org.xerial.snappy/snappy-java "1.0.5-M3"]]}} :aliases {"test-all" ["with-profile" "test,1.3:test,1.4:test,1.5" "test"]} :min-lein-version "2.0.0" :warn-on-reflection true) diff --git a/test/test_nippy/main.clj b/test/test_nippy/main.clj index bec0e6a..185bd68 100644 --- a/test/test_nippy/main.clj +++ b/test/test_nippy/main.clj @@ -15,3 +15,14 @@ (println (benchmarks/autobench)) (println (benchmarks/autobench)) (println (benchmarks/autobench)) + +(deftest test-snappy-library-compatibility + (let [thaw #(nippy/thaw-from-bytes % :compressed? false) + ^bytes raw-ba (nippy/freeze-to-bytes test-data :compress? false) + ^bytes xerial-ba (org.xerial.snappy.Snappy/compress raw-ba) + ^bytes iq80-ba (org.iq80.snappy.Snappy/compress raw-ba)] + (is (= (thaw raw-ba) + (thaw (org.xerial.snappy.Snappy/uncompress xerial-ba)) + (thaw (org.xerial.snappy.Snappy/uncompress iq80-ba)) + (thaw (org.iq80.snappy.Snappy/uncompress iq80-ba 0 (alength iq80-ba))) + (thaw (org.iq80.snappy.Snappy/uncompress xerial-ba 0 (alength xerial-ba))))))) \ No newline at end of file