storm-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bo...@apache.org
Subject [2/4] git commit: Remove magic numbers to be easily understood
Date Tue, 15 Jul 2014 14:21:01 GMT
Remove magic numbers to be easily understood


Project: http://git-wip-us.apache.org/repos/asf/incubator-storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-storm/commit/cc5f1f63
Tree: http://git-wip-us.apache.org/repos/asf/incubator-storm/tree/cc5f1f63
Diff: http://git-wip-us.apache.org/repos/asf/incubator-storm/diff/cc5f1f63

Branch: refs/heads/master
Commit: cc5f1f632a0d4b81ebbf57668ce025a7780b7a0f
Parents: 214ee74
Author: Jungtaek Lim <kabhwan@gmail.com>
Authored: Sat Jul 12 09:23:44 2014 +0900
Committer: Jungtaek Lim <kabhwan@gmail.com>
Committed: Sat Jul 12 09:23:44 2014 +0900

----------------------------------------------------------------------
 .../test/clj/backtype/storm/config_test.clj     | 27 ++++++++++++--------
 1 file changed, 16 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-storm/blob/cc5f1f63/storm-core/test/clj/backtype/storm/config_test.clj
----------------------------------------------------------------------
diff --git a/storm-core/test/clj/backtype/storm/config_test.clj b/storm-core/test/clj/backtype/storm/config_test.clj
index 50970b6..3fdbf5a 100644
--- a/storm-core/test/clj/backtype/storm/config_test.clj
+++ b/storm-core/test/clj/backtype/storm/config_test.clj
@@ -66,28 +66,33 @@
                 (catch Exception e e)))))))
 
 (deftest test-integer-validator
-   (let [validator ConfigValidation/IntegerValidator]
-        (.validateField validator "test" 1000)
-        (is (thrown-cause? java.lang.IllegalArgumentException
-           (.validateField validator "test" 1.34)))
-        (is (thrown-cause? java.lang.IllegalArgumentException
-           (.validateField validator "test" 9223372036854775807)))))
+  (let [validator ConfigValidation/IntegerValidator]
+    (.validateField validator "test" nil)
+    (.validateField validator "test" 1000)
+    (is (thrown-cause? java.lang.IllegalArgumentException
+          (.validateField validator "test" 1.34)))
+    (is (thrown-cause? java.lang.IllegalArgumentException
+          (.validateField validator "test" (inc Integer/MAX_VALUE))))))
 
 (deftest test-integers-validator
   (let [validator ConfigValidation/IntegersValidator]
+    (.validateField validator "test" nil)
     (.validateField validator "test" [1000 0 -1000])
     (is (thrown-cause? java.lang.IllegalArgumentException
           (.validateField validator "test" [0 10 1.34])))
     (is (thrown-cause? java.lang.IllegalArgumentException
-          (.validateField validator "test" [-100 9223372036854775807])))))
+          (.validateField validator "test" [0 nil])))
+    (is (thrown-cause? java.lang.IllegalArgumentException
+          (.validateField validator "test" [-100 (inc Integer/MAX_VALUE)])))))
 
 (deftest test-double-validator
   (let [validator ConfigValidation/DoubleValidator]
+    (.validateField validator "test" nil)
     (.validateField validator "test" 10)
     ;; we can provide lenient way to convert int/long to double with losing precision
-    (.validateField validator "test" 2147483647)
-    (.validateField validator "test" 9223372036854775807)
-    (.validateField validator "test" 1.7976931348623157E308)))
+    (.validateField validator "test" Integer/MAX_VALUE)
+    (.validateField validator "test" (inc Integer/MAX_VALUE))
+    (.validateField validator "test" Double/MAX_VALUE)))
 
 (deftest test-topology-workers-is-integer
   (let [validator (CONFIG-SCHEMA-MAP TOPOLOGY-WORKERS)]
@@ -99,7 +104,7 @@
   (let [validator (CONFIG-SCHEMA-MAP TOPOLOGY-STATS-SAMPLE-RATE)]
     (.validateField validator "test" 0.5)
     (.validateField validator "test" 10)
-    (.validateField validator "test" 1.7976931348623157E308)))
+    (.validateField validator "test" Double/MAX_VALUE)))
 
 (deftest test-isolation-scheduler-machines-is-map
   (let [validator (CONFIG-SCHEMA-MAP ISOLATION-SCHEDULER-MACHINES)]


Mime
View raw message