mod color;
mod commands;
mod ffi;
mod font;
mod renderer;
mod terminal;
pub use ffi::*;
#[cfg(test)]
mod tests {
#![allow(clippy::unwrap_used)]
use super::*;
use crate::ffi::util::state_ref;
use std::ffi::CString;
#[test]
fn table_with_more_than_u16_max_columns_does_not_panic() {
let handle = ratatui_create(10, 5, 14.0);
ratatui_begin_frame(handle);
let data = CString::new(vec!["h"; 65536].join("\t")).unwrap();
ratatui_table(handle, 0, data.as_ptr());
ratatui_end_frame(handle);
ratatui_destroy(handle);
}
#[test]
fn set_custom_font_with_invalid_bytes_returns_zero() {
let handle = ratatui_create(10, 5, 14.0);
let bytes = [0u8; 16];
assert_eq!(ratatui_set_custom_font(handle, bytes.as_ptr(), bytes.len() as u32), 0);
ratatui_destroy(handle);
}
#[test]
fn set_custom_font_resyncs_pixel_dimensions() {
let handle = ratatui_create(10, 5, 14.0);
let bytes = include_bytes!("../fonts/JetBrainsMono-Regular.ttf");
assert_eq!(
ratatui_set_custom_font(handle, bytes.as_ptr(), bytes.len() as u32),
1
);
let w = ratatui_pixel_width(handle);
let h = ratatui_pixel_height(handle);
ratatui_begin_frame(handle);
ratatui_end_frame(handle);
let state = state_ref(handle).unwrap();
assert_eq!(state.pixel_buffer.len(), w as usize * h as usize * 3);
ratatui_destroy(handle);
}
}