Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/plot/layer/geom/density.rs
Original file line number Diff line number Diff line change
Expand Up @@ -605,11 +605,14 @@ fn compute_density(
mod tests {
use super::*;
use crate::plot::Parameters;
#[cfg(feature = "duckdb")]
use crate::reader::duckdb::DuckDBReader;
use crate::reader::AnsiDialect;
#[cfg(feature = "duckdb")]
use crate::reader::Reader;
use arrow::array::Array;

#[cfg(feature = "duckdb")]
#[test]
fn test_density_sql_no_groups() {
let query = "SELECT x FROM (VALUES (1.0), (2.0), (3.0)) AS t(x)";
Expand Down Expand Up @@ -686,6 +689,7 @@ mod tests {
assert_eq!(df.height(), 512); // 512 grid points
}

#[cfg(feature = "duckdb")]
#[test]
fn test_density_sql_with_two_groups() {
let query = "SELECT x, region, category FROM (VALUES (1.0, 'A', 'X'), (2.0, 'B', 'Y')) AS t(x, region, category)";
Expand Down Expand Up @@ -807,6 +811,7 @@ mod tests {
);
}

#[cfg(feature = "duckdb")]
#[test]
fn test_density_sql_computed_bandwidth() {
// Test 1: No groups
Expand Down Expand Up @@ -865,6 +870,7 @@ mod tests {
}

/// Helper function to test that a kernel integrates to 1
#[cfg(feature = "duckdb")]
fn test_kernel_integration(kernel_name: &str, tolerance: f64) {
let query = "SELECT x FROM (VALUES (1.0), (2.0), (3.0), (4.0), (5.0)) AS t(x)";
let groups: Vec<String> = vec![];
Expand Down Expand Up @@ -941,6 +947,7 @@ mod tests {
);
}

#[cfg(feature = "duckdb")]
#[test]
fn test_all_kernels_integrate_to_one() {
let kernels = vec![
Expand Down Expand Up @@ -982,6 +989,7 @@ mod tests {
}
}

#[cfg(feature = "duckdb")]
#[test]
fn test_weighted_vs_unweighted_density() {
// Compare weighted and unweighted results
Expand Down Expand Up @@ -1060,6 +1068,7 @@ mod tests {
}
}

#[cfg(feature = "duckdb")]
#[test]
fn test_density_with_intensity_remapping() {
use crate::reader::duckdb::DuckDBReader;
Expand Down Expand Up @@ -1127,6 +1136,7 @@ mod tests {
println!("✓ Successfully used REMAPPING to map y to intensity instead of density");
}

#[cfg(feature = "duckdb")]
#[test]
#[ignore] // Run with: cargo test bench_density_performance -- --ignored --nocapture
fn bench_density_performance() {
Expand Down
6 changes: 6 additions & 0 deletions src/plot/layer/geom/smooth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,9 +286,12 @@ fn stat_tls(
mod tests {
use super::*;
use crate::plot::AestheticValue;
#[cfg(feature = "duckdb")]
use crate::reader::duckdb::DuckDBReader;
#[cfg(feature = "duckdb")]
use crate::reader::Reader;

#[cfg(feature = "duckdb")]
#[test]
fn test_stat_ols_ungrouped() {
let reader = DuckDBReader::from_connection_string("duckdb://memory").unwrap();
Expand Down Expand Up @@ -338,6 +341,7 @@ mod tests {
}
}

#[cfg(feature = "duckdb")]
#[test]
fn test_stat_ols_grouped() {
let reader = DuckDBReader::from_connection_string("duckdb://memory").unwrap();
Expand Down Expand Up @@ -390,6 +394,7 @@ mod tests {
}
}

#[cfg(feature = "duckdb")]
#[test]
fn test_stat_tls_ungrouped() {
let reader = DuckDBReader::from_connection_string("duckdb://memory").unwrap();
Expand Down Expand Up @@ -439,6 +444,7 @@ mod tests {
}
}

#[cfg(feature = "duckdb")]
#[test]
fn test_stat_tls_grouped() {
let reader = DuckDBReader::from_connection_string("duckdb://memory").unwrap();
Expand Down
6 changes: 6 additions & 0 deletions src/plot/layer/geom/violin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,10 @@ mod tests {
use super::*;
use crate::plot::AestheticValue;
use crate::plot::Parameters;
#[cfg(feature = "duckdb")]
use crate::reader::duckdb::DuckDBReader;
use crate::reader::AnsiDialect;
#[cfg(feature = "duckdb")]
use crate::reader::Reader;
use arrow::array::Array;

Expand Down Expand Up @@ -323,6 +325,7 @@ mod tests {

// ==================== Basic Behavior Tests ====================

#[cfg(feature = "duckdb")]
#[test]
fn test_violin_no_extra_groups() {
// Test violin with just x and y (no additional grouping variables)
Expand Down Expand Up @@ -387,6 +390,7 @@ mod tests {
}
}

#[cfg(feature = "duckdb")]
#[test]
fn test_violin_with_extra_groups() {
// Test violin with x, y, and an additional color grouping variable
Expand Down Expand Up @@ -484,6 +488,7 @@ mod tests {
}
}

#[cfg(feature = "duckdb")]
#[test]
fn test_violin_tails_parameter() {
// Verify that the violin geom has a tails parameter with default 3.0
Expand Down Expand Up @@ -624,6 +629,7 @@ mod tests {
assert!((values[2] - 0.3).abs() < 1e-6, "1.0 should become 0.3");
}

#[cfg(feature = "duckdb")]
#[test]
fn test_violin_dummy_pos1_when_unmapped() {
// pos2 only - pos1 omitted should produce a single violin via dummy x.
Expand Down
4 changes: 2 additions & 2 deletions src/plot/projection/coord/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1265,8 +1265,8 @@ mod tests {
Err(crate::GgsqlError::InternalError("no db".into()))
}

fn noop_dialect() -> crate::reader::duckdb::DuckDbDialect {
crate::reader::duckdb::DuckDbDialect
fn noop_dialect() -> crate::reader::AnsiDialect {
crate::reader::AnsiDialect
}

mod scale_override_bbox_tests {
Expand Down
1 change: 1 addition & 0 deletions src/reader/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ mod duckdb_tests {
);
}

#[cfg(feature = "vegalite")]
#[test]
fn test_ribbon_transposed_vegalite_encoding() {
use crate::reader::Reader;
Expand Down
8 changes: 8 additions & 0 deletions src/reader/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1637,6 +1637,7 @@ mod tests {
);
}

#[cfg(feature = "builtin-data")]
#[test]
fn test_stacked_bar_chart_dummy_x() {
// Test stacked bar chart with no x mapping (dummy x column)
Expand Down Expand Up @@ -1671,6 +1672,7 @@ mod tests {
);
}

#[cfg(feature = "builtin-data")]
#[test]
fn test_boxplot_dummy_x() {
// Boxplot with only y mapped: should render a single boxplot of the
Expand All @@ -1697,6 +1699,7 @@ mod tests {
);
}

#[cfg(feature = "builtin-data")]
#[test]
fn test_violin_dummy_x() {
// Violin with only y mapped: single violin spanning the whole dataset.
Expand All @@ -1720,6 +1723,7 @@ mod tests {
);
}

#[cfg(feature = "builtin-data")]
#[test]
fn test_point_dummy_x() {
// Point with only y mapped: strip plot at a single dummy x position.
Expand Down Expand Up @@ -1767,6 +1771,7 @@ mod tests {
);
}

#[cfg(feature = "builtin-data")]
#[test]
fn test_point_dummy_y() {
// Symmetric to test_point_dummy_x: only x mapped means dummy y.
Expand All @@ -1790,6 +1795,7 @@ mod tests {
);
}

#[cfg(feature = "builtin-data")]
#[test]
fn test_point_dummy_both_with_aggregate() {
// Both axes omitted, but aggregate gives the single point meaning:
Expand Down Expand Up @@ -1820,6 +1826,7 @@ mod tests {
);
}

#[cfg(feature = "builtin-data")]
#[test]
fn test_point_dummy_x_with_aggregate() {
// Point with aggregate SETTING and no x mapping: should aggregate the
Expand All @@ -1845,6 +1852,7 @@ mod tests {
);
}

#[cfg(feature = "builtin-data")]
#[test]
fn test_bar_chart_with_expand_setting() {
// Test bar chart with SCALE y SETTING expand - should work even when y is stat-derived
Expand Down
2 changes: 2 additions & 0 deletions src/reader/sqlite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -819,6 +819,7 @@ mod tests {
assert_eq!(df.column_dtype("y").unwrap(), DataType::Int64);
}

#[cfg(feature = "vegalite")]
#[test]
fn test_subquery_vegalite_quantitative() {
use crate::writer::{VegaLiteWriter, Writer};
Expand Down Expand Up @@ -1213,6 +1214,7 @@ mod tests {
assert_eq!(result.column_dtype("name").unwrap(), DataType::Utf8);
}

#[cfg(feature = "vegalite")]
#[test]
fn test_date_vegalite_temporal() {
use crate::writer::{VegaLiteWriter, Writer};
Expand Down
6 changes: 6 additions & 0 deletions src/writer/hephaestus/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1012,6 +1012,7 @@ mod tests {
));
}

#[cfg(feature = "builtin-data")]
#[test]
fn renders_free_binned_facet() {
// A free binned position dimension: each panel keeps ggsql's global bin
Expand All @@ -1023,6 +1024,7 @@ mod tests {
);
}

#[cfg(feature = "builtin-data")]
#[test]
fn renders_binned_size_legend() {
// A binned *keyed* legend: one key per bin, sized at the bin's midpoint,
Expand All @@ -1034,6 +1036,7 @@ mod tests {
);
}

#[cfg(feature = "builtin-data")]
#[test]
fn renders_binned_color_legend() {
// The same ladder driving color: a stepped colorbar, one block per bin.
Expand Down Expand Up @@ -1110,6 +1113,7 @@ mod tests {
);
}

#[cfg(feature = "builtin-data")]
#[test]
fn renders_jittered_points() {
// `position => 'jitter'` spreads the points across their category band;
Expand Down Expand Up @@ -1147,6 +1151,7 @@ mod tests {
);
}

#[cfg(feature = "builtin-data")]
#[test]
fn renders_jitter_with_half_boxplot() {
// The documented raincloud layout: a one-sided jitter above the
Expand Down Expand Up @@ -1385,6 +1390,7 @@ mod svg_text {
}
}

#[cfg(feature = "builtin-data")]
#[test]
fn a_binned_scales_edge_labels_reach_the_legend() {
// The renderer cannot derive a bin ladder, so all five edges appearing
Expand Down
11 changes: 11 additions & 0 deletions src/writer/vegalite/layer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3142,6 +3142,7 @@ mod tests {
}
}

#[cfg(feature = "duckdb")]
#[test]
fn test_text_angle_integration() {
use crate::execute;
Expand Down Expand Up @@ -3260,6 +3261,7 @@ mod tests {
}
}

#[cfg(feature = "duckdb")]
#[test]
fn test_text_offset_parameters() {
use crate::execute;
Expand Down Expand Up @@ -3327,6 +3329,7 @@ mod tests {
}
}

#[cfg(feature = "duckdb")]
#[test]
fn test_text_label_formatting() {
use crate::execute;
Expand Down Expand Up @@ -3384,6 +3387,7 @@ mod tests {
assert!(labels.contains(&"Region: East Region"));
}

#[cfg(feature = "duckdb")]
#[test]
fn test_text_label_formatting_numeric() {
use crate::execute;
Expand Down Expand Up @@ -3427,6 +3431,7 @@ mod tests {
assert!(labels.contains(&"$21.00"));
}

#[cfg(feature = "duckdb")]
#[test]
fn test_text_label_newline_splitting() {
use crate::execute;
Expand Down Expand Up @@ -3502,6 +3507,7 @@ mod tests {
assert_eq!(annotation_lines[1].as_str().unwrap(), "With Newline");
}

#[cfg(feature = "duckdb")]
#[test]
fn test_text_setting_fontweight() {
use crate::execute;
Expand Down Expand Up @@ -3559,6 +3565,7 @@ mod tests {
}
}

#[cfg(feature = "duckdb")]
#[test]
fn test_text_setting_fontweight_numeric() {
use crate::execute;
Expand Down Expand Up @@ -3597,6 +3604,7 @@ mod tests {
}
}

#[cfg(feature = "duckdb")]
#[test]
fn test_text_setting_fontweight_numeric_normal() {
use crate::execute;
Expand Down Expand Up @@ -3635,6 +3643,7 @@ mod tests {
}
}

#[cfg(feature = "duckdb")]
#[test]
fn test_text_setting_fontweight_keywords() {
use crate::execute;
Expand Down Expand Up @@ -4378,6 +4387,7 @@ mod tests {
.contains("no valid numeric range"));
}

#[cfg(feature = "duckdb")]
#[test]
fn test_rule_renderer_multiple_diagonal_lines() {
use crate::reader::{DuckDBReader, Reader};
Expand Down Expand Up @@ -4560,6 +4570,7 @@ mod tests {
);
}

#[cfg(feature = "duckdb")]
#[test]
fn test_sloped_rule_renderer_horizontal_orientation() {
use crate::reader::{DuckDBReader, Reader};
Expand Down
1 change: 1 addition & 0 deletions src/writer/vegalite/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1562,6 +1562,7 @@ mod tests {
assert_eq!(vl_spec["layer"][0]["mark"]["clip"], true);
}

#[cfg(feature = "duckdb")]
#[test]
fn test_labels_newline_splitting() {
use crate::execute;
Expand Down
Loading
Loading