Skip to content

Commit

Permalink
Implement get_columns on Tabulator
Browse files Browse the repository at this point in the history
  • Loading branch information
k88hudson-cfa committed Nov 26, 2024
1 parent 278cddd commit 837e679
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/people.rs
Original file line number Diff line number Diff line change
@@ -102,6 +102,7 @@ seq!(Z in 1..20 {

pub trait Tabulator {
fn get_typelist(&self) -> Vec<TypeId>;
fn get_columns(&self) -> Vec<String>;
}

macro_rules! impl_tabulator {
@@ -124,6 +125,14 @@ macro_rules! impl_tabulator {
)*
]
}

fn get_columns(&self) -> Vec<String> {
vec![
#(
String::from(std::any::type_name::<T~N>().split("::").last().unwrap()),
)*
]
}
}
});
}
@@ -1154,7 +1163,9 @@ impl ContextPeopleExtInternal for Context {

#[cfg(test)]
mod test {
use super::{ContextPeopleExt, PersonCreatedEvent, PersonId, PersonPropertyChangeEvent};
use super::{
ContextPeopleExt, PersonCreatedEvent, PersonId, PersonPropertyChangeEvent, Tabulator,
};
use crate::{
context::Context,
error::IxaError,
@@ -1834,6 +1845,16 @@ mod test {
assert_ne!(IndexValue::compute(&value1), IndexValue::compute(&value2));
}

#[test]
fn test_tabulator() {
let cols = (Age, RiskCategoryType);
assert_eq!(
cols.get_typelist(),
vec![TypeId::of::<Age>(), TypeId::of::<RiskCategoryType>()]
);
assert_eq!(cols.get_columns(), vec!["Age", "RiskCategoryType"]);
}

#[test]
fn test_get_counts() {
let mut context = Context::new();

0 comments on commit 837e679

Please sign in to comment.