#![cfg(any(feature = "embed-ipadic", feature = "embed-unidic"))]
use lindera::dictionary::load_dictionary;
fn assert_embedded_matrix_is_borrowed(uri: &str) {
let dictionary = load_dictionary(uri).expect("embedded dictionary should load");
let matrix = &dictionary.connection_cost_matrix;
assert!(
matrix.is_zero_copy(),
"{uri}: the embedded connection cost matrix must be borrowed, not copied. \
The payload starts at byte 6 of matrix.mtx, so the backing static needs \
at least 2-byte alignment -- check that embedded_dictionary! still uses \
include_bytes_aligned! for CONNECTION_DATA."
);
assert_eq!(
matrix.costs().len() as u32,
matrix.forward_size * matrix.backward_size
);
}
#[test]
#[cfg(feature = "embed-ipadic")]
fn embedded_ipadic_matrix_is_zero_copy() {
assert_embedded_matrix_is_borrowed("embedded://ipadic");
}
#[test]
#[cfg(feature = "embed-unidic")]
fn embedded_unidic_matrix_is_zero_copy() {
assert_embedded_matrix_is_borrowed("embedded://unidic");
}