You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by ks...@apache.org on 2018/09/07 09:18:52 UTC

[arrow] branch master updated: ARROW-3177: [Rust] Update expected error messages for tests that 'should panic'

This is an automated email from the ASF dual-hosted git repository.

kszucs pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git


The following commit(s) were added to refs/heads/master by this push:
     new 5d4d6ba  ARROW-3177: [Rust] Update expected error messages for tests that 'should panic'
5d4d6ba is described below

commit 5d4d6ba23101fe8617ec706e6a761c9f99c7e7c3
Author: Paddy Horan <pa...@hotmail.com>
AuthorDate: Fri Sep 7 11:18:41 2018 +0200

    ARROW-3177: [Rust] Update expected error messages for tests that 'should panic'
    
    Author: Paddy Horan <pa...@hotmail.com>
    
    Closes #2519 from paddyhoran/ARROW-3177 and squashes the following commits:
    
    f56f7e40 <Paddy Horan> Added expected error messages to tests
---
 rust/src/array.rs   | 22 ++++++++++++----------
 rust/src/buffer.rs  |  2 +-
 rust/src/builder.rs |  6 +++---
 3 files changed, 16 insertions(+), 14 deletions(-)

diff --git a/rust/src/array.rs b/rust/src/array.rs
index b21e604..c42928f 100644
--- a/rust/src/array.rs
+++ b/rust/src/array.rs
@@ -440,7 +440,7 @@ impl From<ArrayDataRef> for BinaryArray {
         let raw_value_offsets = data.buffers()[0].raw_data();
         assert!(
             memory::is_aligned(raw_value_offsets, mem::align_of::<i32>()),
-            "memory not aligned"
+            "memory is not aligned"
         );
         let value_data = data.buffers()[1].raw_data();
         Self {
@@ -599,7 +599,9 @@ mod tests {
     }
 
     #[test]
-    #[should_panic(expected = "")]
+    #[should_panic(
+        expected = "PrimitiveArray data should contain a single buffer only (values buffer)"
+    )]
     fn test_primitive_array_invalid_buffer_len() {
         let data = ArrayData::builder(DataType::Int32).len(5).build();
         PrimitiveArray::<i32>::from(data);
@@ -657,7 +659,7 @@ mod tests {
     }
 
     #[test]
-    #[should_panic(expected = "")]
+    #[should_panic(expected = "ListArray data should contain a single buffer only (value offsets)")]
     fn test_list_array_invalid_buffer_len() {
         let value_data = ArrayData::builder(DataType::Int32)
             .len(7)
@@ -672,7 +674,7 @@ mod tests {
     }
 
     #[test]
-    #[should_panic(expected = "")]
+    #[should_panic(expected = "ListArray should contain a single child array (values array)")]
     fn test_list_array_invalid_child_array_len() {
         let value_offsets = Buffer::from(&[0, 2, 5, 7].to_byte_slice());
         let list_data_type = DataType::List(Box::new(DataType::Int32));
@@ -684,7 +686,7 @@ mod tests {
     }
 
     #[test]
-    #[should_panic(expected = "")]
+    #[should_panic(expected = "offsets do not start at zero")]
     fn test_list_array_invalid_value_offset_start() {
         let value_data = ArrayData::builder(DataType::Int32)
             .len(7)
@@ -703,7 +705,7 @@ mod tests {
     }
 
     #[test]
-    #[should_panic(expected = "")]
+    #[should_panic(expected = "inconsistent offsets buffer and values array")]
     fn test_list_array_invalid_value_offset_end() {
         let value_data = ArrayData::builder(DataType::Int32)
             .len(7)
@@ -769,7 +771,7 @@ mod tests {
     }
 
     #[test]
-    #[should_panic(expected = "")]
+    #[should_panic(expected = "BinaryArray out of bounds access")]
     fn test_binary_array_get_value_index_out_of_bound() {
         let values: [u8; 12] = [
             b'h', b'e', b'l', b'l', b'o', b'p', b'a', b'r', b'q', b'u', b'e', b't',
@@ -808,7 +810,7 @@ mod tests {
     }
 
     #[test]
-    #[should_panic(expected = "")]
+    #[should_panic(expected = "memory is not aligned")]
     fn test_primitive_array_alignment() {
         let ptr = memory::allocate_aligned(8).unwrap();
         let buf = Buffer::from_raw_parts(ptr, 8);
@@ -818,7 +820,7 @@ mod tests {
     }
 
     #[test]
-    #[should_panic(expected = "")]
+    #[should_panic(expected = "memory is not aligned")]
     fn test_list_array_alignment() {
         let ptr = memory::allocate_aligned(8).unwrap();
         let buf = Buffer::from_raw_parts(ptr, 8);
@@ -838,7 +840,7 @@ mod tests {
     }
 
     #[test]
-    #[should_panic(expected = "")]
+    #[should_panic(expected = "memory is not aligned")]
     fn test_binary_array_alignment() {
         let ptr = memory::allocate_aligned(8).unwrap();
         let buf = Buffer::from_raw_parts(ptr, 8);
diff --git a/rust/src/buffer.rs b/rust/src/buffer.rs
index f50b19c..1cad425 100644
--- a/rust/src/buffer.rs
+++ b/rust/src/buffer.rs
@@ -215,7 +215,7 @@ mod tests {
     }
 
     #[test]
-    #[should_panic(expected = "")]
+    #[should_panic(expected = "the offset of the new Buffer cannot exceed the existing length")]
     fn test_slice_offset_out_of_bound() {
         let buf = Buffer::from(&[2, 4, 6, 8, 10]);
         buf.slice(6);
diff --git a/rust/src/builder.rs b/rust/src/builder.rs
index 58eac4a..8b5438e 100644
--- a/rust/src/builder.rs
+++ b/rust/src/builder.rs
@@ -237,21 +237,21 @@ mod tests {
     }
 
     #[test]
-    #[should_panic]
+    #[should_panic(expected = "the end of the slice must be within the capacity")]
     fn test_slice_start_out_of_bounds() {
         let mut b: Builder<u8> = Builder::with_capacity(2);
         b.slice_mut(3, 3); // should panic
     }
 
     #[test]
-    #[should_panic]
+    #[should_panic(expected = "the end of the slice must be within the capacity")]
     fn test_slice_end_out_of_bounds() {
         let mut b: Builder<u8> = Builder::with_capacity(2);
         b.slice_mut(0, 3); // should panic
     }
 
     #[test]
-    #[should_panic]
+    #[should_panic(expected = "the start of the slice cannot exceed the end of the slice")]
     fn test_slice_end_before_start() {
         let mut b: Builder<u8> = Builder::with_capacity(2);
         b.slice_mut(1, 0); // should panic