From: Ben Pfaff Date: Fri, 11 Apr 2025 14:28:20 +0000 (-0700) Subject: one more test X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f5968982226e26724030691c4f23237caf2c9352;p=pspp one more test --- diff --git a/rust/pspp/src/output/pivot/test.rs b/rust/pspp/src/output/pivot/test.rs index c0e851ba40..b683992ae4 100644 --- a/rust/pspp/src/output/pivot/test.rs +++ b/rust/pspp/src/output/pivot/test.rs @@ -635,32 +635,36 @@ Empty Groups ); } -fn d4(title: &str, borders: EnumMap) -> PivotTable { +fn d4( + title: &str, + borders: EnumMap, + show_dimension_labels: bool, +) -> PivotTable { let a = Dimension::builder( Axis3::X, Group::builder("a") - .with_label_shown() + .with_show_label(show_dimension_labels) .with("a1") .with(Group::builder("ag1").with("a2").with("a3")), ); let b = Dimension::builder( Axis3::X, Group::builder("b") - .with_label_shown() + .with_show_label(show_dimension_labels) .with(Group::builder("bg1").with("b1").with("b2")) .with("b3"), ); let c = Dimension::builder( Axis3::Y, Group::builder("c") - .with_label_shown() + .with_show_label(show_dimension_labels) .with("c1") .with(Group::builder("cg1").with("c2").with("c3")), ); let d = Dimension::builder( Axis3::Y, Group::builder("d") - .with_label_shown() + .with_show_label(show_dimension_labels) .with(Group::builder("dg1").with("d1").with("d2")) .with("d3"), ); @@ -686,12 +690,10 @@ fn dimension_borders_1() { "Dimension Borders 1", EnumMap::from_fn(|border| match border { Border::Dimension(RowColBorder(HeadingRegion::Rows, Axis2::X)) - | Border::Dimension(RowColBorder(HeadingRegion::Columns, Axis2::Y)) => BorderStyle { - stroke: Stroke::Solid, - color: Color::BLUE, - }, + | Border::Dimension(RowColBorder(HeadingRegion::Columns, Axis2::Y)) => SOLID_BLUE, _ => BorderStyle::none(), }), + true, ); assert_rendering( &pivot_table, @@ -727,12 +729,10 @@ fn dimension_borders_2() { "Dimension Borders 2", EnumMap::from_fn(|border| match border { Border::Dimension(RowColBorder(HeadingRegion::Rows, Axis2::Y)) - | Border::Dimension(RowColBorder(HeadingRegion::Columns, Axis2::X)) => BorderStyle { - stroke: Stroke::Solid, - color: Color::BLUE, - }, + | Border::Dimension(RowColBorder(HeadingRegion::Columns, Axis2::X)) => SOLID_BLUE, _ => BorderStyle::none(), }), + true, ); assert_rendering( &pivot_table, @@ -764,12 +764,10 @@ fn category_borders_1() { "Category Borders 1", EnumMap::from_fn(|border| match border { Border::Category(RowColBorder(HeadingRegion::Rows, Axis2::X)) - | Border::Category(RowColBorder(HeadingRegion::Columns, Axis2::Y)) => BorderStyle { - stroke: Stroke::Dashed, - color: Color::RED, - }, + | Border::Category(RowColBorder(HeadingRegion::Columns, Axis2::Y)) => DASHED_RED, _ => BorderStyle::none(), }), + true, ); assert_rendering( &pivot_table, @@ -808,12 +806,10 @@ fn category_borders_2() { "Category Borders 2", EnumMap::from_fn(|border| match border { Border::Category(RowColBorder(HeadingRegion::Rows, Axis2::Y)) - | Border::Category(RowColBorder(HeadingRegion::Columns, Axis2::X)) => BorderStyle { - stroke: Stroke::Dashed, - color: Color::RED, - }, + | Border::Category(RowColBorder(HeadingRegion::Columns, Axis2::X)) => DASHED_RED, _ => BorderStyle::none(), }), + true, ); assert_rendering( &pivot_table, @@ -849,17 +845,12 @@ fn category_and_dimension_borders_1() { "Category and Dimension Borders 1", EnumMap::from_fn(|border| match border { Border::Dimension(RowColBorder(HeadingRegion::Rows, Axis2::X)) - | Border::Dimension(RowColBorder(HeadingRegion::Columns, Axis2::Y)) => BorderStyle { - stroke: Stroke::Solid, - color: Color::BLUE, - }, + | Border::Dimension(RowColBorder(HeadingRegion::Columns, Axis2::Y)) => SOLID_BLUE, Border::Category(RowColBorder(HeadingRegion::Rows, Axis2::X)) - | Border::Category(RowColBorder(HeadingRegion::Columns, Axis2::Y)) => BorderStyle { - stroke: Stroke::Dashed, - color: Color::RED, - }, + | Border::Category(RowColBorder(HeadingRegion::Columns, Axis2::Y)) => DASHED_RED, _ => BorderStyle::none(), }), + true, ); assert_rendering( &pivot_table, @@ -898,17 +889,12 @@ fn category_and_dimension_borders_2() { "Category and Dimension Borders 2", EnumMap::from_fn(|border| match border { Border::Dimension(RowColBorder(HeadingRegion::Rows, Axis2::Y)) - | Border::Dimension(RowColBorder(HeadingRegion::Columns, Axis2::X)) => BorderStyle { - stroke: Stroke::Solid, - color: Color::BLUE, - }, + | Border::Dimension(RowColBorder(HeadingRegion::Columns, Axis2::X)) => SOLID_BLUE, Border::Category(RowColBorder(HeadingRegion::Rows, Axis2::Y)) - | Border::Category(RowColBorder(HeadingRegion::Columns, Axis2::X)) => BorderStyle { - stroke: Stroke::Dashed, - color: Color::RED, - }, + | Border::Category(RowColBorder(HeadingRegion::Columns, Axis2::X)) => DASHED_RED, _ => BorderStyle::none(), }), + true, ); assert_rendering( &pivot_table, @@ -937,3 +923,56 @@ dg1┊d1│ c1 0 1 2 3 4 5 6 7 8 ", ); } + +const SOLID_BLUE: BorderStyle = BorderStyle { + stroke: Stroke::Solid, + color: Color::BLUE, +}; + +const DASHED_RED: BorderStyle = BorderStyle { + stroke: Stroke::Dashed, + color: Color::RED, +}; + +#[test] +fn category_and_dimension_borders_3() { + let pivot_table = d4( + "Category and Dimension Borders 3", + EnumMap::from_fn(|border| match border { + Border::Dimension(_) => SOLID_BLUE, + Border::Category(_) => DASHED_RED, + _ => BorderStyle::none(), + }), + false, + ); + assert_rendering( + &pivot_table, + "\ +Category and Dimension Borders 3 + bg1 │ + ╌╌╌╌╌╌╌╌╌┬╌╌╌╌╌╌╌╌┤ + b1 │ b2 │ b3 + ╶──┬─────┼──┬─────┼──┬───── + │ ag1 │ │ ag1 │ │ ag1 + ├╌╌┬╌╌┤ ├╌╌┬╌╌┤ ├╌╌┬╌╌ + a1│a2┊a3│a1│a2┊a3│a1│a2┊a3 +dg1┊d1│ c1 0│ 1┊ 2│ 3│ 4┊ 5│ 6│ 7┊ 8 + ┊ ├───┬─────┼──┼──┼──┼──┼──┼──┼──┼── + ┊ │cg1┊c2 9│10┊11│12│13┊14│15│16┊17 + ┊ │ ├╌╌╌╌╌┼╌╌+╌╌┼╌╌┼╌╌+╌╌┼╌╌┼╌╌+╌╌ + ┊ │ ┊c3 18│19┊20│21│22┊23│24│25┊26 + ├──┼───┴─────┼──┼──┼──┼──┼──┼──┼──┼── + ┊d2│ c1 27│28┊29│30│31┊32│33│34┊35 + ┊ ├───┬─────┼──┼──┼──┼──┼──┼──┼──┼── + ┊ │cg1┊c2 36│37┊38│39│40┊41│42│43┊44 + ┊ │ ├╌╌╌╌╌┼╌╌+╌╌┼╌╌┼╌╌+╌╌┼╌╌┼╌╌+╌╌ + ┊ │ ┊c3 45│46┊47│48│49┊50│51│52┊53 +───┴──┼───┴─────┼──┼──┼──┼──┼──┼──┼──┼── + d3│ c1 54│55┊56│57│58┊59│60│61┊62 + ├───┬─────┼──┼──┼──┼──┼──┼──┼──┼── + │cg1┊c2 63│64┊65│66│67┊68│69│70┊71 + │ ├╌╌╌╌╌┼╌╌+╌╌┼╌╌┼╌╌+╌╌┼╌╌┼╌╌+╌╌ + │ ┊c3 72│73┊74│75│76┊77│78│79┊80 +", + ); +}