mirror of
https://github.com/quickwit-oss/tantivy.git
synced 2026-01-04 16:22:55 +00:00
enable test
This commit is contained in:
@@ -126,7 +126,8 @@ impl<'a, T: Copy + PartialOrd + Send + Sync> Column<T> for VecColumn<'a, T> {
|
||||
}
|
||||
|
||||
impl<'a, T: Copy + Ord + Default, V> From<&'a V> for VecColumn<'a, T>
|
||||
where V: AsRef<[T]> + ?Sized
|
||||
where
|
||||
V: AsRef<[T]> + ?Sized,
|
||||
{
|
||||
fn from(values: &'a V) -> Self {
|
||||
let values = values.as_ref();
|
||||
@@ -223,7 +224,8 @@ where
|
||||
pub struct IterColumn<T>(T);
|
||||
|
||||
impl<T> From<T> for IterColumn<T>
|
||||
where T: Iterator + Clone + ExactSizeIterator
|
||||
where
|
||||
T: Iterator + Clone + ExactSizeIterator,
|
||||
{
|
||||
fn from(iter: T) -> Self {
|
||||
IterColumn(iter)
|
||||
@@ -259,20 +261,23 @@ where
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
// use crate::MonotonicallyMappableToU64;
|
||||
use crate::monotonic_mapping::{
|
||||
StrictlyMonotonicMappingInverter, StrictlyMonotonicMappingToInternalBaseval,
|
||||
StrictlyMonotonicMappingToInternalGCDBaseval,
|
||||
};
|
||||
|
||||
//#[test]
|
||||
// fn test_monotonic_mapping() {
|
||||
// let vals = &[1u64, 3u64][..];
|
||||
// let col = VecColumn::from(vals);
|
||||
// let mapped = monotonic_map_column(col, |el| el + 4, |_el| unimplemented!());
|
||||
// assert_eq!(mapped.min_value(), 5u64);
|
||||
// assert_eq!(mapped.max_value(), 7u64);
|
||||
// assert_eq!(mapped.num_vals(), 2);
|
||||
// assert_eq!(mapped.num_vals(), 2);
|
||||
// assert_eq!(mapped.get_val(0), 5);
|
||||
// assert_eq!(mapped.get_val(1), 7);
|
||||
//}
|
||||
#[test]
|
||||
fn test_monotonic_mapping() {
|
||||
let vals = &[3u64, 5u64][..];
|
||||
let col = VecColumn::from(vals);
|
||||
let mapped = monotonic_map_column(col, StrictlyMonotonicMappingToInternalBaseval::new(2));
|
||||
assert_eq!(mapped.min_value(), 1u64);
|
||||
assert_eq!(mapped.max_value(), 3u64);
|
||||
assert_eq!(mapped.num_vals(), 2);
|
||||
assert_eq!(mapped.num_vals(), 2);
|
||||
assert_eq!(mapped.get_val(0), 1);
|
||||
assert_eq!(mapped.get_val(1), 3);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_range_as_col() {
|
||||
@@ -281,34 +286,44 @@ mod tests {
|
||||
assert_eq!(col.max_value(), 99);
|
||||
}
|
||||
|
||||
//#[test]
|
||||
// fn test_monotonic_mapping_iter() {
|
||||
// let vals: Vec<u64> = (-1..99).map(i64::to_u64).collect();
|
||||
// let col = VecColumn::from(&vals);
|
||||
// let mapped =
|
||||
// monotonic_map_column(col, |el| i64::from_u64(el) * 10i64, |_| unimplemented!());
|
||||
// let val_i64s: Vec<i64> = mapped.iter().collect();
|
||||
// for i in 0..100 {
|
||||
// assert_eq!(val_i64s[i as usize], mapped.get_val(i));
|
||||
//}
|
||||
#[test]
|
||||
fn test_monotonic_mapping_iter() {
|
||||
let vals: Vec<u64> = (10..110u64).map(|el| el * 10).collect();
|
||||
let col = VecColumn::from(&vals);
|
||||
let mapped = monotonic_map_column(
|
||||
col,
|
||||
StrictlyMonotonicMappingInverter::from(
|
||||
StrictlyMonotonicMappingToInternalGCDBaseval::new(10, 100),
|
||||
),
|
||||
);
|
||||
let val_i64s: Vec<u64> = mapped.iter().collect();
|
||||
for i in 0..100 {
|
||||
assert_eq!(val_i64s[i as usize], mapped.get_val(i));
|
||||
}
|
||||
}
|
||||
|
||||
//#[test]
|
||||
// fn test_monotonic_mapping_get_range() {
|
||||
// let vals: Vec<u64> = (-1..99).map(i64::to_u64).collect();
|
||||
// let col = VecColumn::from(&vals);
|
||||
// let mapped =
|
||||
// monotonic_map_column(col, |el| i64::from_u64(el) * 10i64, |_| unimplemented!());
|
||||
// assert_eq!(mapped.min_value(), -10i64);
|
||||
// assert_eq!(mapped.max_value(), 980i64);
|
||||
// assert_eq!(mapped.num_vals(), 100);
|
||||
// let val_i64s: Vec<i64> = mapped.iter().collect();
|
||||
// assert_eq!(val_i64s.len(), 100);
|
||||
// for i in 0..100 {
|
||||
// assert_eq!(val_i64s[i as usize], mapped.get_val(i));
|
||||
// assert_eq!(val_i64s[i as usize], i64::from_u64(vals[i as usize]) * 10);
|
||||
//}
|
||||
// let mut buf = [0i64; 20];
|
||||
// mapped.get_range(7, &mut buf[..]);
|
||||
// assert_eq!(&val_i64s[7..][..20], &buf);
|
||||
//}
|
||||
#[test]
|
||||
fn test_monotonic_mapping_get_range() {
|
||||
let vals: Vec<u64> = (0..100u64).map(|el| el * 10).collect();
|
||||
let col = VecColumn::from(&vals);
|
||||
let mapped = monotonic_map_column(
|
||||
col,
|
||||
StrictlyMonotonicMappingInverter::from(
|
||||
StrictlyMonotonicMappingToInternalGCDBaseval::new(10, 0),
|
||||
),
|
||||
);
|
||||
|
||||
assert_eq!(mapped.min_value(), 0u64);
|
||||
assert_eq!(mapped.max_value(), 9900u64);
|
||||
assert_eq!(mapped.num_vals(), 100);
|
||||
let val_u64s: Vec<u64> = mapped.iter().collect();
|
||||
assert_eq!(val_u64s.len(), 100);
|
||||
for i in 0..100 {
|
||||
assert_eq!(val_u64s[i as usize], mapped.get_val(i));
|
||||
assert_eq!(val_u64s[i as usize], vals[i as usize] * 10);
|
||||
}
|
||||
let mut buf = [0u64; 20];
|
||||
mapped.get_range(7, &mut buf[..]);
|
||||
assert_eq!(&val_u64s[7..][..20], &buf);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user