#![cfg(feature = "str")]
extern crate alloc;
use alloc::sync::Arc;
#[cfg(feature = "serde")]
use flexstr::LocalStr;
#[cfg(any(feature = "prost", feature = "serde", feature = "utoipa"))]
use flexstr::SharedStr;
use inline_flexstr::INLINE_CAPACITY;
mod common;
#[cfg(feature = "serde")]
#[test]
fn serialize_deserialize_test_local_str() {
common::serialize::serialize_deserialize_test::<LocalStr, str>("test");
}
#[cfg(feature = "serde")]
#[test]
fn serialize_deserialize_test_shared_str() {
common::serialize::serialize_deserialize_test::<SharedStr, str>("test");
}
#[test]
fn test_creation_from_borrowed_str() {
common::basic::test_creation_from_borrowed::<str, Arc<str>>("test");
}
#[test]
fn test_creation_from_owned_str() {
common::basic::test_creation_from_owned::<str, Arc<str>>("test".to_string());
}
#[test]
fn test_creation_from_inline_str() {
common::basic::test_creation_from_inline::<str, Arc<str>>("test");
}
#[test]
fn test_creation_from_ref_counted_str() {
common::basic::test_creation_from_ref_counted::<str, Arc<str>>("test".into());
}
#[test]
fn test_creation_from_boxed_str() {
common::basic::test_creation_from_boxed::<str, Arc<str>>("test");
}
#[test]
fn test_empty_str() {
common::basic::test_empty::<str, Arc<str>>("");
}
#[test]
fn test_accessors_str() {
common::basic::test_accessors::<str, Arc<str>>("test");
}
#[test]
fn test_clone_all_variants_str() {
common::basic::test_clone_all_variants::<str, Arc<str>>("test");
}
#[test]
fn test_default_str() {
common::basic::test_default::<str, Arc<str>>();
}
#[test]
fn test_to_owned_str() {
common::conversion::test_to_owned::<str, Arc<str>>("test");
}
#[test]
fn test_into_owned_str() {
common::conversion::test_into_owned::<str, Arc<str>>("test");
}
#[test]
fn test_to_owned_type_str() {
common::conversion::test_to_owned_type::<str, Arc<str>>("test");
}
#[test]
fn test_into_owned_type_str() {
common::conversion::test_into_owned_type::<str, Arc<str>>("test");
}
#[test]
fn test_to_local_str() {
common::conversion::test_to_local::<str>("test");
}
#[test]
fn test_into_local_str() {
common::conversion::test_into_local::<str>("test");
}
#[test]
fn test_to_shared_str() {
common::conversion::test_to_shared::<str>("test");
}
#[test]
fn test_into_shared_str() {
common::conversion::test_into_shared::<str>("test");
}
#[test]
fn test_optimize_str() {
common::conversion::test_optimize::<str, Arc<str>>("test");
}
#[test]
fn test_from_borrowed_ref_str() {
common::conversion::test_from_borrowed_ref::<str, Arc<str>>("test");
}
#[test]
fn test_from_box_str() {
common::conversion::test_from_box::<str, Arc<str>>("test");
}
#[test]
fn test_from_inline_flex_str_str() {
common::conversion::test_from_inline_flex_str::<str, Arc<str>>("test");
}
#[test]
fn test_from_cow_str() {
common::conversion::test_from_cow::<str, Arc<str>>("test");
}
#[test]
fn test_partial_eq_str() {
common::comparison::test_partial_eq::<str, Arc<str>>("test", "test");
common::comparison::test_partial_eq::<str, Arc<str>>("test", "other");
}
#[test]
fn test_eq_str() {
common::comparison::test_eq::<str, Arc<str>>("test");
}
#[test]
fn test_partial_ord_str() {
common::comparison::test_partial_ord::<str, Arc<str>>("a", "b");
}
#[test]
fn test_ord_str() {
common::comparison::test_ord::<str, Arc<str>>("a", "b");
}
#[test]
fn test_hash_str() {
common::comparison::test_hash::<str, Arc<str>>("test");
}
#[test]
fn test_comparison_with_ref_str() {
common::comparison::test_comparison_with_ref::<str, Arc<str>>("test");
}
#[test]
fn test_comparison_with_owned_str() {
common::comparison::test_comparison_with_owned::<str, Arc<str>>("test");
}
#[test]
fn test_comparison_with_inline_str() {
common::comparison::test_comparison_with_inline::<str, Arc<str>>("test");
}
#[test]
fn test_partial_eq_with_owned_types_str() {
common::comparison::test_partial_eq_with_owned_types::<str, Arc<str>>("test");
}
#[test]
fn test_variant_queries_str() {
common::storage::test_variant_queries::<str, Arc<str>>("test");
}
#[test]
fn test_transition_borrowed_to_inlined_str() {
common::storage::test_transition_borrowed_to_inlined::<str, Arc<str>>("test");
}
#[test]
fn test_transition_borrowed_to_ref_counted_str() {
common::storage::test_transition_borrowed_to_ref_counted::<str, Arc<str>>(
"this is a very long string that definitely won't fit inline",
);
}
#[test]
fn test_transition_inlined_to_ref_counted_str() {
common::storage::test_transition_inlined_to_ref_counted::<str, Arc<str>>("test");
}
#[test]
fn test_transition_boxed_to_optimized_str() {
common::storage::test_transition_boxed_to_optimized::<str, Arc<str>>("test");
}
#[test]
fn test_storage_optimization_str() {
common::storage::test_storage_optimization::<str, Arc<str>>("test");
}
#[test]
fn test_empty_string_str() {
common::edge_cases::test_empty_string::<str, Arc<str>>("");
}
#[test]
fn test_capacity_boundary_exact_str() {
let s = "a".repeat(INLINE_CAPACITY);
let s_static: &'static str = Box::leak(s.into_boxed_str());
common::edge_cases::test_capacity_boundary_exact::<str, Arc<str>>(s_static);
}
#[test]
fn test_capacity_boundary_overflow_str() {
common::edge_cases::test_capacity_boundary_overflow::<str>("test");
}
#[test]
fn test_try_from_too_long_str() {
common::edge_cases::test_try_from_too_long();
}
#[test]
fn test_various_lengths_str() {
common::edge_cases::test_various_lengths::<str, Arc<str>>("test");
common::edge_cases::test_various_lengths::<str, Arc<str>>("");
common::edge_cases::test_various_lengths::<str, Arc<str>>("a");
}
#[test]
fn test_special_content_str() {
common::edge_cases::test_special_content::<str, Arc<str>>("test");
common::edge_cases::test_special_content::<str, Arc<str>>("hello\nworld");
common::edge_cases::test_special_content::<str, Arc<str>>("🚀");
}
#[test]
fn test_clone_variants_str() {
common::edge_cases::test_clone_variants::<str, Arc<str>>("test");
}
#[test]
fn test_too_long_for_inlining() {
common::errors::test_too_long_for_inlining();
}
#[test]
fn test_too_long_or_utf8_error_too_long() {
common::errors::test_too_long_or_utf8_error_too_long();
}
#[test]
fn test_too_long_or_utf8_error_utf8() {
common::errors::test_too_long_or_utf8_error_utf8();
}
#[test]
fn test_as_str() {
common::stringlike::test_as_str::<str, Arc<str>>("test");
}
#[test]
fn test_into_string() {
common::stringlike::test_into_string::<str, Arc<str>>("test");
}
#[test]
fn test_to_string() {
common::stringlike::test_to_string::<str, Arc<str>>("test");
}
#[test]
fn test_try_from_bytes_invalid_utf8() {
common::try_from::test_try_from_bytes_invalid_utf8::<Arc<str>>();
}
#[test]
fn test_try_from_vec_bytes_invalid_utf8() {
common::try_from::test_try_from_vec_bytes_invalid_utf8::<Arc<str>>();
}
#[test]
fn test_from_string() {
common::from::test_from_string_str::<Arc<str>>();
}
#[test]
fn test_from_str_flex_str_success() {
common::from_str::test_from_str_flex_str_success::<str, Arc<str>>("test");
}
#[test]
fn test_optimize_ref_counted_to_inlined() {
common::inline_edge_cases::test_optimize_ref_counted_to_inlined::<str, Arc<str>>("test");
}
#[test]
fn test_optimize_ref_counted_stays_ref_counted() {
let long_str: &'static str = Box::leak(Box::new("x".repeat(INLINE_CAPACITY + 1)));
common::inline_edge_cases::test_optimize_ref_counted_stays_ref_counted::<str, Arc<str>>(
long_str,
);
}
#[test]
fn test_mutation_borrowed_str() {
common::mutate::test_mutation_borrowed::<str, Arc<str>>("test");
}
#[test]
fn test_mutation_inlined_str() {
common::mutate::test_mutation_inlined::<str, Arc<str>>("test");
}
#[test]
fn test_mutation_ref_counted_str() {
common::mutate::test_mutation_ref_counted::<str, Arc<str>>("test".into());
}
#[test]
fn test_mutation_boxed_str() {
common::mutate::test_mutation_boxed::<str, Arc<str>>("test".into());
}
#[test]
fn test_display_str() {
common::display::test_display::<str, Arc<str>>("test");
}
#[test]
fn test_borrow_str() {
common::borrow::test_borrow::<str, Arc<str>>("test");
}
#[test]
fn test_index_str() {
common::index::test_index::<str, Arc<str>>("test");
}
#[cfg(feature = "std")]
#[test]
fn test_to_socket_addrs_str() {
common::socket::test_to_socket_addrs::<str, Arc<str>>("127.0.0.1:8080");
}
#[cfg(feature = "std")]
#[test]
fn test_try_from_osstr_str() {
common::try_from::test_try_from_osstr_str::<Arc<str>>();
}
#[cfg(feature = "std")]
#[test]
fn test_try_from_path_str() {
common::try_from::test_try_from_path_str::<Arc<str>>();
}
#[test]
fn test_try_from_vec_u8_str() {
common::try_from::test_try_from_vec_u8_str::<Arc<str>>();
}
#[cfg(feature = "cstr")]
#[test]
fn test_try_from_cstring_str() {
common::try_from::test_try_from_cstring_str::<Arc<str>>();
}
#[cfg(feature = "cstr")]
#[test]
fn test_from_str_cstr_success() {
common::from_str::test_from_str_cstr_success::<Arc<core::ffi::CStr>>();
}
#[cfg(feature = "cstr")]
#[test]
fn test_from_str_cstr_error() {
common::from_str::test_from_str_cstr_error::<Arc<core::ffi::CStr>>();
}
#[test]
fn test_as_ref_str_flex_str() {
common::as_ref::test_as_ref_str_flex_str::<Arc<str>>("test");
}
#[cfg(feature = "prost")]
#[test]
fn prost_encode_decode_shared_str() {
common::prost::encode_decode_round_trip::<SharedStr>("test");
}
#[cfg(feature = "prost")]
#[test]
fn prost_encode_decode_shared_str_long() {
common::prost::encode_decode_round_trip::<SharedStr>(
"this is a very long string that definitely won't fit inline",
);
}
#[cfg(feature = "prost")]
#[test]
fn prost_encode_decode_shared_str_empty() {
common::prost::encode_decode_round_trip::<SharedStr>("");
}
#[cfg(feature = "prost")]
#[test]
fn prost_encode_decode_shared_str_unicode() {
common::prost::encode_decode_round_trip::<SharedStr>("hello 🌍🚀");
}
#[cfg(feature = "prost")]
#[test]
fn prost_length_delimited_shared_str() {
common::prost::encode_length_delimited_round_trip::<SharedStr>("test");
}
#[cfg(feature = "prost")]
#[test]
fn prost_wire_format_shared_str() {
common::prost::verify_wire_format::<SharedStr>("test");
common::prost::verify_wire_format::<SharedStr>("");
common::prost::verify_wire_format::<SharedStr>("hello 🌍🚀");
}
#[cfg(feature = "prost")]
#[test]
fn prost_decode_empty_shared_str() {
common::prost::decode_empty::<SharedStr>();
}
#[cfg(feature = "prost")]
#[test]
fn prost_clear_shared_str() {
common::prost::clear_test::<SharedStr>("test");
}
#[cfg(feature = "prost")]
#[test]
fn prost_encode_decode_inline_str() {
use inline_flexstr::InlineStr;
common::prost::encode_decode_round_trip::<InlineStr>("test");
}
#[cfg(feature = "prost")]
#[test]
fn prost_encode_decode_inline_str_empty() {
use inline_flexstr::InlineStr;
common::prost::encode_decode_round_trip::<InlineStr>("");
}
#[cfg(feature = "prost")]
#[test]
fn prost_wire_format_inline_str() {
use inline_flexstr::InlineStr;
common::prost::verify_wire_format::<InlineStr>("test");
common::prost::verify_wire_format::<InlineStr>("");
}
#[cfg(feature = "prost")]
#[test]
fn prost_decode_empty_inline_str() {
use inline_flexstr::InlineStr;
common::prost::decode_empty::<InlineStr>();
}
#[cfg(feature = "prost")]
#[test]
fn prost_clear_inline_str() {
use inline_flexstr::InlineStr;
common::prost::clear_test::<InlineStr>("test");
}
#[cfg(feature = "prost")]
#[test]
fn prost_inline_str_too_long() {
use inline_flexstr::InlineStr;
use prost::Message;
let long: SharedStr = "this is a very long string that definitely won't fit inline".into();
let encoded = long.encode_to_vec();
let result = InlineStr::decode(&encoded[..]);
assert!(
result.is_err(),
"should fail for string too long for inline storage"
);
}
#[cfg(feature = "prost")]
#[test]
fn prost_cross_type_wire_compat_shared_str() {
common::prost::cross_type_wire_compat::<SharedStr>("test");
common::prost::cross_type_wire_compat::<SharedStr>("hello 🌍🚀");
common::prost::cross_type_wire_compat::<SharedStr>("");
common::prost::cross_type_wire_compat::<SharedStr>(
"this is a very long string that definitely won't fit inline",
);
}
#[cfg(feature = "prost")]
#[test]
fn prost_cross_type_wire_compat_inline_str() {
use inline_flexstr::InlineStr;
common::prost::cross_type_wire_compat::<InlineStr>("test");
common::prost::cross_type_wire_compat::<InlineStr>("");
}
#[cfg(feature = "prost")]
#[test]
fn prost_encode_shared_str_decode_string() {
common::prost::encode_flex_decode_string::<SharedStr>("test");
common::prost::encode_flex_decode_string::<SharedStr>("hello 🌍🚀");
common::prost::encode_flex_decode_string::<SharedStr>("");
common::prost::encode_flex_decode_string::<SharedStr>(
"this is a very long string that definitely won't fit inline",
);
}
#[cfg(feature = "prost")]
#[test]
fn prost_encode_inline_str_decode_string() {
use inline_flexstr::InlineStr;
common::prost::encode_flex_decode_string::<InlineStr>("test");
common::prost::encode_flex_decode_string::<InlineStr>("");
}
#[cfg(feature = "prost")]
#[test]
fn prost_encode_string_decode_shared_str() {
common::prost::encode_string_decode_flex::<SharedStr>("test");
common::prost::encode_string_decode_flex::<SharedStr>("hello 🌍🚀");
common::prost::encode_string_decode_flex::<SharedStr>("");
common::prost::encode_string_decode_flex::<SharedStr>(
"this is a very long string that definitely won't fit inline",
);
}
#[cfg(feature = "prost")]
#[test]
fn prost_encode_string_decode_inline_str() {
use inline_flexstr::InlineStr;
common::prost::encode_string_decode_flex::<InlineStr>("test");
common::prost::encode_string_decode_flex::<InlineStr>("");
}
#[cfg(feature = "utoipa")]
#[test]
fn utoipa_schema_is_string_shared_str() {
common::utoipa::schema_is_string::<SharedStr>();
}
#[cfg(feature = "utoipa")]
#[test]
fn utoipa_name_is_string_shared_str() {
common::utoipa::name_is_string::<SharedStr>();
}
#[cfg(feature = "utoipa")]
#[test]
fn utoipa_schema_is_string_inline_str() {
use inline_flexstr::InlineStr;
common::utoipa::schema_is_string::<InlineStr>();
}
#[cfg(feature = "utoipa")]
#[test]
fn utoipa_name_is_string_inline_str() {
use inline_flexstr::InlineStr;
common::utoipa::name_is_string::<InlineStr>();
}
#[cfg(feature = "zeroize")]
#[test]
fn test_zeroize_inlined_str() {
common::zeroize::test_zeroize_inlined::<str, Arc<str>>("test");
}
#[cfg(feature = "zeroize")]
#[test]
fn test_zeroize_borrowed_str() {
common::zeroize::test_zeroize_borrowed::<str, Arc<str>>("test");
}
#[cfg(feature = "zeroize")]
#[test]
fn test_zeroize_ref_counted_str() {
common::zeroize::test_zeroize_ref_counted::<str, Arc<str>>("test".into());
}
#[cfg(feature = "zeroize")]
#[test]
fn test_zeroize_ref_counted_shared_str() {
common::zeroize::test_zeroize_ref_counted_shared::<str, Arc<str>>("test".into());
}
#[cfg(feature = "zeroize")]
#[test]
fn test_zeroize_boxed_str() {
common::zeroize::test_zeroize_boxed::<str, Arc<str>>("test");
}
#[cfg(feature = "zeroize")]
#[test]
fn test_zeroize_inline_bytes_cleared_str() {
common::zeroize::test_zeroize_inline_bytes_cleared::<str>("test");
}