1pub mod commit;
2pub mod emoji;
3pub mod matcher;
4
5pub use commit::{GitCommit, GitError};
7pub use emoji::{EMOJI_MAP, EmojiLookup};
8pub use matcher::{GitmojiMatcher, MatcherFactory, MatcherResult};
9
10#[cfg(feature = "llm")]
12pub use matcher::llm::{LLMConfig, LLMMatcher, LLMModel, LLMProvider, LLMWithFallbackMatcher};
13
14pub fn add(left: u64, right: u64) -> u64 {
15 left + right
16}
17
18#[cfg(test)]
19mod tests {
20 use super::*;
21 use crate::matcher::MatcherFactory;
22
23 #[test]
24 fn test_library_integration() {
25 let matcher = MatcherFactory::simple();
27
28 let emoji = EmojiLookup::code_to_unicode(":sparkles:");
30 assert_eq!(emoji, Some("✨"));
31
32 let result = matcher.match_emoji("fix critical bug").unwrap();
34 assert!(result.is_some());
35 let (code, format_message) = result.unwrap();
36 assert_eq!(code, ":bug:");
37 assert_eq!(format_message, ":bug: fix critical bug");
38
39 let emoji_unicode = EmojiLookup::code_to_unicode(&code);
41 assert_eq!(emoji_unicode, Some("🐛"));
42 }
43
44 #[test]
45 fn test_end_to_end_workflow() {
46 let matcher = MatcherFactory::simple();
48
49 let test_cases = vec![
50 ("add user authentication", ":sparkles:", "✨"),
51 ("fix memory leak", ":bug:", "🐛"),
52 ("update documentation", ":memo:", "📝"),
53 ("add unit tests", ":white_check_mark:", "✅"),
54 ];
55
56 for (message, expected_code, expected_emoji) in test_cases {
57 let match_result = matcher.match_emoji(message).unwrap();
59 assert!(match_result.is_some());
60
61 let (code, format_message) = match_result.unwrap();
62
63 let emoji_from_lookup = EmojiLookup::code_to_unicode(&code);
65 assert!(emoji_from_lookup.is_some());
66
67 assert!(format_message.contains(message));
69 assert!(format_message.starts_with(&code));
70
71 if code == expected_code {
73 assert_eq!(emoji_from_lookup.unwrap(), expected_emoji);
74 }
75 }
76 }
77
78 #[test]
79 fn test_public_api_exports() {
80 let _commit = GitCommit::format_message(":sparkles:", "test");
84
85 let _emoji = EmojiLookup::code_to_unicode(":sparkles:");
87
88 let _result: MatcherResult = Some((
90 ":sparkles:".to_string(),
91 ":sparkles: test message".to_string(),
92 ));
93
94 assert!(!EMOJI_MAP.is_empty());
96 }
97
98 #[test]
99 fn test_error_handling_integration() {
100 let invalid_emoji = EmojiLookup::code_to_unicode(":nonexistent:");
104 assert!(invalid_emoji.is_none());
105
106 let commit_result = GitCommit::commit("test message", true);
108 assert!(commit_result.is_ok());
109
110 let matcher = MatcherFactory::simple();
112 let edge_cases = vec!["", " ", "\n\t", "🎉🐛✨"];
113
114 for case in edge_cases {
115 let result = matcher.match_emoji(case);
116 assert!(result.is_ok());
117 assert!(result.unwrap().is_some()); }
119 }
120
121 #[test]
122 fn test_data_consistency() {
123 let matcher = MatcherFactory::simple();
125
126 let test_messages = vec![
127 "fix bug",
128 "add feature",
129 "update docs",
130 "run tests",
131 "refactor code",
132 ];
133
134 for message in test_messages {
135 let result = matcher.match_emoji(message).unwrap();
136 assert!(result.is_some());
137
138 let (code, format_message) = result.unwrap();
139
140 let lookup_emoji = EmojiLookup::code_to_unicode(&code);
142 assert!(lookup_emoji.is_some());
143
144 assert!(format_message.contains(message));
146 assert!(format_message.starts_with(&code));
147 }
148 }
149
150 #[test]
151 fn test_performance_basic() {
152 let matcher = MatcherFactory::simple();
154
155 let start = std::time::Instant::now();
156
157 for i in 0..1000 {
159 let message = format!("fix bug number {i}");
160 let _result = matcher.match_emoji(&message).unwrap();
161 }
162
163 let duration = start.elapsed();
164
165 assert!(
167 duration.as_secs() < 1,
168 "Performance test took too long: {duration:?}"
169 );
170 }
171
172 #[test]
174 fn it_works() {
175 let result = add(2, 2);
176 assert_eq!(result, 4);
177 }
178}