use arrow2::array::*;
use super::test_equal;
fn create_dictionary_array(values: &[Option<&str>], keys: &[Option<i16>]) -> DictionaryArray<i16> {
let keys = Int16Array::from(keys);
let values = Utf8Array::<i32>::from(values);
DictionaryArray::try_from_keys(keys, values.boxed()).unwrap()
}
#[test]
fn dictionary_equal() {
let a = create_dictionary_array(
&[Some("a"), Some("b"), Some("c")],
&[Some(0), Some(1), Some(0), Some(2)],
);
let b = create_dictionary_array(
&[Some("a"), Some("c"), Some("b")],
&[Some(0), Some(2), Some(0), Some(1)],
);
test_equal(&a, &b, true);
let b = create_dictionary_array(
&[Some("a"), Some("c"), Some("b")],
&[Some(0), Some(2), Some(1)],
);
test_equal(&a, &b, false);
let b = create_dictionary_array(
&[Some("a"), Some("c"), Some("b")],
&[Some(0), Some(2), Some(0), Some(0)],
);
test_equal(&a, &b, false);
let b = create_dictionary_array(
&[Some("a"), Some("b"), Some("d")],
&[Some(0), Some(1), Some(0), Some(2)],
);
test_equal(&a, &b, false);
}
#[test]
fn dictionary_equal_null() {
let a = create_dictionary_array(
&[Some("a"), Some("b"), Some("c")],
&[Some(0), None, Some(0), Some(2)],
);
test_equal(&a, &a, true);
let b = create_dictionary_array(
&[Some("a"), Some("c"), Some("b")],
&[Some(0), None, Some(0), Some(1)],
);
test_equal(&a, &b, true);
let b = create_dictionary_array(
&[Some("a"), Some("c"), Some("b")],
&[Some(0), Some(2), Some(0), None],
);
test_equal(&a, &b, false);
let b = create_dictionary_array(
&[Some("a"), Some("c"), Some("b")],
&[Some(0), None, Some(0), Some(0)],
);
test_equal(&a, &b, false);
let b = create_dictionary_array(
&[Some("a"), Some("b"), Some("d")],
&[Some(0), None, Some(0), Some(2)],
);
test_equal(&a, &b, false);
let a = create_dictionary_array(
&[Some("a"), Some("b"), None],
&[Some(0), None, Some(0), Some(2)],
);
let b = create_dictionary_array(
&[Some("a"), Some("b"), Some("c")],
&[Some(0), None, Some(0), None],
);
test_equal(&a, &b, true);
}