tajo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hyun...@apache.org
Subject tajo git commit: TAJO-1180: digitValue should throw Exception when char is not in valid range. (DaeMyung Kang via hyunsik)
Date Mon, 05 Jan 2015 21:31:24 GMT
Repository: tajo
Updated Branches:
  refs/heads/master cb9793b99 -> 203a146b2


TAJO-1180: digitValue should throw Exception when char is not in valid range. (DaeMyung Kang
via hyunsik)

Closes #246


Project: http://git-wip-us.apache.org/repos/asf/tajo/repo
Commit: http://git-wip-us.apache.org/repos/asf/tajo/commit/203a146b
Tree: http://git-wip-us.apache.org/repos/asf/tajo/tree/203a146b
Diff: http://git-wip-us.apache.org/repos/asf/tajo/diff/203a146b

Branch: refs/heads/master
Commit: 203a146b278a88853054bb6bd9ad7699e7268b8a
Parents: cb9793b
Author: Hyunsik Choi <hyunsik@apache.org>
Authored: Tue Jan 6 06:21:20 2015 +0900
Committer: Hyunsik Choi <hyunsik@apache.org>
Committed: Tue Jan 6 06:21:35 2015 +0900

----------------------------------------------------------------------
 CHANGES                                         |  3 ++
 .../apache/tajo/datum/protobuf/TextUtils.java   |  4 +-
 .../tajo/datum/protobuf/TestTextUtils.java      | 52 ++++++++++++++++++++
 3 files changed, 58 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tajo/blob/203a146b/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 8a4ffe1..6e7a3c6 100644
--- a/CHANGES
+++ b/CHANGES
@@ -137,6 +137,9 @@ Release 0.9.1 - unreleased
 
   BUG FIXES
 
+    TAJO-1180: digitValue should throw Exception when char is not in 
+    valid range. (DaeMyung Kang via hyunsik)
+
     TAJO-1276: Link to tsql guide 404s in tajo cli. (Jakob Homan via jihoon)
 
     TAJO-1275: Optimizer pushs down non-equi filter as theta join qualifier.

http://git-wip-us.apache.org/repos/asf/tajo/blob/203a146b/tajo-common/src/main/java/org/apache/tajo/datum/protobuf/TextUtils.java
----------------------------------------------------------------------
diff --git a/tajo-common/src/main/java/org/apache/tajo/datum/protobuf/TextUtils.java b/tajo-common/src/main/java/org/apache/tajo/datum/protobuf/TextUtils.java
index 8eaff79..ecffd32 100644
--- a/tajo-common/src/main/java/org/apache/tajo/datum/protobuf/TextUtils.java
+++ b/tajo-common/src/main/java/org/apache/tajo/datum/protobuf/TextUtils.java
@@ -114,8 +114,10 @@ public class TextUtils {
         return c - '0';
       } else if ('a' <= c && c <= 'z') {
         return c - 'a' + 10;
-      } else {
+      } else if ('A' <= c && c <= 'Z') {
         return c - 'A' + 10;
+      } else {
+        throw new IllegalArgumentException("Expected \"0-9\" or \"a-z, A-Z\".");
       }
     }
     

http://git-wip-us.apache.org/repos/asf/tajo/blob/203a146b/tajo-common/src/test/java/org/apache/tajo/datum/protobuf/TestTextUtils.java
----------------------------------------------------------------------
diff --git a/tajo-common/src/test/java/org/apache/tajo/datum/protobuf/TestTextUtils.java b/tajo-common/src/test/java/org/apache/tajo/datum/protobuf/TestTextUtils.java
new file mode 100644
index 0000000..5efd027
--- /dev/null
+++ b/tajo-common/src/test/java/org/apache/tajo/datum/protobuf/TestTextUtils.java
@@ -0,0 +1,52 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tajo.datum.protobuf;
+
+import org.junit.Test;
+
+import java.io.IOException;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+
+public class TestTextUtils {
+
+  @Test
+  public void testDigitValueSuccess() {
+      assertEquals(TextUtils.digitValue('0'), 0);
+      assertEquals(TextUtils.digitValue('a'), 10);
+      assertEquals(TextUtils.digitValue('A'), 10);
+      assertEquals(TextUtils.digitValue('f'), 15);
+      assertEquals(TextUtils.digitValue('F'), 15);
+      assertEquals(TextUtils.digitValue('z'), 35);
+      assertEquals(TextUtils.digitValue('Z'), 35);
+  }
+
+  @Test
+  public void testDigitValueError() throws IllegalArgumentException {
+      boolean ret = true;
+      try {
+        TextUtils.digitValue('!');
+      } catch(IllegalArgumentException e) {
+        ret = false;
+      }
+
+      assertFalse(ret);
+  }
+}


Mime
View raw message