enumerated_latin 1.0.0

Encodes short strings as numeric values
Documentation
#![warn(missing_docs)]
#![doc = include_str!("../README.md")]

// SPDX-FileCopyrightText: 2025 Slatian
//
// SPDX-License-Identifier: LGPL-3.0-only

mod decode;
mod decoding_style;
mod encode;
mod encoding_target;

pub use decode::EnumeratedLatinDecode;
pub use encode::EncodingError;
pub use encode::EnumeratedLatinEncode;
pub use encoding_target::EncodingTarget;

#[cfg(test)]
mod test {
	use super::*;

	// End-to-end test encoding to `u64`, decoding to lowercase, expecting success
	fn end_to_end(text: &str) {
		let n: u64 = text
			.enumerated_latin_encode()
			.expect(format!("Encode text: '{text}'").as_str());
		assert_eq!(
			n.enumerated_latin_decode_lowercase(),
			Some(text.to_lowercase().to_string())
		);
	}

	#[test]
	fn end_to_end_empty() {
		end_to_end("");
	}

	#[test]
	fn end_to_end_text() {
		end_to_end("a");
		end_to_end("z");
		end_to_end("A");
		end_to_end("Z");
		end_to_end("blubber");
		end_to_end("DIGNITY");
		end_to_end("qaa");
		end_to_end("qq");
		end_to_end("HelloWorld");
		end_to_end("WAAAAAHHHHH");
		end_to_end("HumanRights");
		end_to_end("zzzzzzzzzzzzz"); // Maximum length for u64
		end_to_end("aaaaaaaaaaaaa"); // Maximum length for u64
	}

	fn end_to_end_test_next(text: &str, next: &str) {
		let text_n: u64 = text
			.enumerated_latin_encode()
			.expect(format!("Encode text: '{text}'").as_str());
		assert_eq!(
			(text_n + 1).enumerated_latin_decode_lowercase(),
			Some(next.to_lowercase().to_string())
		);
	}

	#[test]
	fn ordered_encoding() {
		end_to_end_test_next("a", "b");
		end_to_end_test_next("y", "z");
		end_to_end_test_next("aaa", "aab");
		end_to_end_test_next("aaz", "aba");
		end_to_end_test_next("qzz", "raa");
		end_to_end_test_next("qrs", "qrt");
	}
}