Repository: vxquery
Updated Branches:
  refs/heads/master 7d7ab007e -> 015c5f6ca


Improved the sequence test to correctly identify the item types.


Project: http://git-wip-us.apache.org/repos/asf/vxquery/repo
Commit: http://git-wip-us.apache.org/repos/asf/vxquery/commit/015c5f6c
Tree: http://git-wip-us.apache.org/repos/asf/vxquery/tree/015c5f6c
Diff: http://git-wip-us.apache.org/repos/asf/vxquery/diff/015c5f6c

Branch: refs/heads/master
Commit: 015c5f6ca6bc58db1930da8dd4cbe506d51232ca
Parents: 7d7ab00
Author: Preston Carman <[email protected]>
Authored: Tue May 17 07:14:05 2016 -0700
Committer: Preston Carman <[email protected]>
Committed: Tue May 17 07:14:05 2016 -0700

----------------------------------------------------------------------
 .../datamodel/AbstractPointableTest.java        | 11 +++++++++-
 .../vxquery/datamodel/SequenceByteTest.java     | 23 +++++++++++++++-----
 2 files changed, 27 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/vxquery/blob/015c5f6c/vxquery-core/src/test/java/org/apache/vxquery/datamodel/AbstractPointableTest.java
----------------------------------------------------------------------
diff --git 
a/vxquery-core/src/test/java/org/apache/vxquery/datamodel/AbstractPointableTest.java
 
b/vxquery-core/src/test/java/org/apache/vxquery/datamodel/AbstractPointableTest.java
index 9343465..fa4e831 100644
--- 
a/vxquery-core/src/test/java/org/apache/vxquery/datamodel/AbstractPointableTest.java
+++ 
b/vxquery-core/src/test/java/org/apache/vxquery/datamodel/AbstractPointableTest.java
@@ -28,16 +28,25 @@ public class AbstractPointableTest {
 
     protected void getTaggedValuePointable(Object value, IPointable result) 
throws IOException {
         int start = abvsInput.getLength();
-        if (value instanceof java.lang.Long) {
+        if (value instanceof java.lang.Integer) {
+            writeInteger((Integer) value, abvsInput.getDataOutput());
+        } else if (value instanceof java.lang.Long) {
             writeLong((Long) value, abvsInput.getDataOutput());
         } else if (value instanceof java.lang.Double) {
             writeDouble((Double) value, abvsInput.getDataOutput());
         } else if (value instanceof java.lang.String) {
             writeString((String) value, abvsInput.getDataOutput());
+        } else {
+            throw new IOException("Unknown object type for tagged value 
pointable.");
         }
         result.set(abvsInput.getByteArray(), start, abvsInput.getLength() - 
start);
     }
 
+    protected void writeInteger(Integer value, DataOutput dOut) throws 
IOException {
+        dOut.write(ValueTag.XS_INT_TAG);
+        dOut.writeInt(value);
+    }
+
     protected void writeLong(Long value, DataOutput dOut) throws IOException {
         dOut.write(ValueTag.XS_LONG_TAG);
         dOut.writeLong(value);

http://git-wip-us.apache.org/repos/asf/vxquery/blob/015c5f6c/vxquery-core/src/test/java/org/apache/vxquery/datamodel/SequenceByteTest.java
----------------------------------------------------------------------
diff --git 
a/vxquery-core/src/test/java/org/apache/vxquery/datamodel/SequenceByteTest.java 
b/vxquery-core/src/test/java/org/apache/vxquery/datamodel/SequenceByteTest.java
index 776b97a..54cf105 100644
--- 
a/vxquery-core/src/test/java/org/apache/vxquery/datamodel/SequenceByteTest.java
+++ 
b/vxquery-core/src/test/java/org/apache/vxquery/datamodel/SequenceByteTest.java
@@ -29,10 +29,9 @@ import junit.framework.Assert;
 
 /**
  * The sequence byte test covers empty sequences, single items and multi-item 
sequences.
- *
  * 1. Empty sequence constant
  * 2. Empty sequence - {}
- * 3. Single item - "one" (XQuery single item sequences are just the item.)
+ * 3. Single item - 1l (XQuery single item sequences are just the item.)
  * 4. Many items - {1, 2.0, "three"}
  */
 public class SequenceByteTest extends AbstractPointableTest {
@@ -85,7 +84,7 @@ public class SequenceByteTest extends AbstractPointableTest {
         // Build test sequence
         try {
             sb.reset(abvsResult);
-            getTaggedValuePointable("one", tvp1);
+            getTaggedValuePointable(1l, tvp1);
             sb.addItem(tvp1);
             sb.finish();
         } catch (IOException e) {
@@ -94,8 +93,8 @@ public class SequenceByteTest extends AbstractPointableTest {
         tvp.set(abvsResult);
 
         // Check results.
-        if (tvp.getTag() != ValueTag.XS_STRING_TAG) {
-            Assert.fail("Type tag is incorrect. Expected: " + 
ValueTag.XS_STRING_TAG + " Got: " + tvp.getTag());
+        if (tvp.getTag() != ValueTag.XS_LONG_TAG) {
+            Assert.fail("Type tag is incorrect. Expected: " + 
ValueTag.XS_LONG_TAG + " Got: " + tvp.getTag());
         }
         if (!FunctionHelper.arraysEqual(tvp, tvp1)) {
             Assert.fail("Item value is incorrect.");
@@ -129,15 +128,27 @@ public class SequenceByteTest extends 
AbstractPointableTest {
             Assert.fail("Sequence size is incorrect. Expected: 3 Got: " + 
sp.getEntryCount());
         }
         sp.getEntry(0, tvp);
+        if (tvp.getTag() != ValueTag.XS_INT_TAG) {
+            Assert.fail("Sequence item one type tag is incorrect. Expected: " 
+ ValueTag.XS_INT_TAG + " Got: "
+                    + tvp.getTag());
+        }
         if (!FunctionHelper.arraysEqual(tvp, tvp1)) {
-            Assert.fail("Sequence item one is incorrect. Expected: " + 
ValueTag.XS_LONG_TAG + " Got: " + tvp.getTag());
+            Assert.fail("Sequence item one is incorrect. Expected: " + 
ValueTag.XS_INT_TAG + " Got: " + tvp.getTag());
         }
         sp.getEntry(1, tvp);
+        if (tvp.getTag() != ValueTag.XS_DOUBLE_TAG) {
+            Assert.fail("Sequence item two type tag is incorrect. Expected: " 
+ ValueTag.XS_DOUBLE_TAG + " Got: "
+                    + tvp.getTag());
+        }
         if (!FunctionHelper.arraysEqual(tvp, tvp2)) {
             Assert.fail(
                     "Sequence item two is incorrect. Expected: " + 
ValueTag.XS_DOUBLE_TAG + " Got: " + tvp.getTag());
         }
         sp.getEntry(2, tvp);
+        if (tvp.getTag() != ValueTag.XS_STRING_TAG) {
+            Assert.fail("Sequence item three type tag is incorrect. Expected: 
" + ValueTag.XS_STRING_TAG + " Got: "
+                    + tvp.getTag());
+        }
         if (!FunctionHelper.arraysEqual(tvp, tvp3)) {
             Assert.fail(
                     "Sequence item three is incorrect. Expected: " + 
ValueTag.XS_STRING_TAG + " Got: " + tvp.getTag());

Reply via email to