1use serde::{Deserialize, Serialize};
4use std::fmt;
5use std::path::PathBuf;
6
7pub use crate::tokenizer::{TokenCounts, TokenModel};
9
10pub type TokenizerModel = TokenModel;
41
42#[derive(Debug, Clone, Serialize, Deserialize)]
44pub struct Repository {
45 pub name: String,
47 pub path: PathBuf,
49 pub files: Vec<RepoFile>,
51 pub metadata: RepoMetadata,
53}
54
55impl Repository {
56 pub fn new(name: impl Into<String>, path: impl Into<PathBuf>) -> Self {
58 Self {
59 name: name.into(),
60 path: path.into(),
61 files: Vec::new(),
62 metadata: RepoMetadata::default(),
63 }
64 }
65
66 pub fn total_tokens(&self, model: TokenizerModel) -> u32 {
68 self.files.iter().map(|f| f.token_count.get(model)).sum()
69 }
70
71 pub fn files_by_language(&self, language: &str) -> Vec<&RepoFile> {
73 self.files
74 .iter()
75 .filter(|f| f.language.as_deref() == Some(language))
76 .collect()
77 }
78
79 #[must_use]
81 pub fn files_by_importance(&self) -> Vec<&RepoFile> {
82 let mut files: Vec<_> = self.files.iter().collect();
83 files.sort_by(|a, b| {
84 b.importance
85 .partial_cmp(&a.importance)
86 .unwrap_or(std::cmp::Ordering::Equal)
87 });
88 files
89 }
90}
91
92impl fmt::Display for Repository {
93 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
94 write!(
95 f,
96 "Repository({}: {} files, {} lines)",
97 self.name, self.metadata.total_files, self.metadata.total_lines
98 )
99 }
100}
101
102#[derive(Debug, Clone, Serialize, Deserialize)]
104pub struct RepoFile {
105 pub path: PathBuf,
107 pub relative_path: String,
109 pub language: Option<String>,
111 pub size_bytes: u64,
113 pub token_count: TokenCounts,
115 pub symbols: Vec<Symbol>,
117 pub importance: f32,
119 pub content: Option<String>,
121}
122
123impl RepoFile {
124 pub fn new(path: impl Into<PathBuf>, relative_path: impl Into<String>) -> Self {
126 Self {
127 path: path.into(),
128 relative_path: relative_path.into(),
129 language: None,
130 size_bytes: 0,
131 token_count: TokenCounts::default(),
132 symbols: Vec::new(),
133 importance: 0.5,
134 content: None,
135 }
136 }
137
138 pub fn extension(&self) -> Option<&str> {
140 self.path.extension().and_then(|e| e.to_str())
141 }
142
143 #[must_use]
145 pub fn filename(&self) -> &str {
146 self.path.file_name().and_then(|n| n.to_str()).unwrap_or("")
147 }
148}
149
150impl fmt::Display for RepoFile {
151 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
152 write!(
153 f,
154 "{} ({}, {} tokens)",
155 self.relative_path,
156 self.language.as_deref().unwrap_or("unknown"),
157 self.token_count.claude
158 )
159 }
160}
161
162#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Serialize, Deserialize)]
164pub enum Visibility {
165 #[default]
166 Public,
167 Private,
168 Protected,
169 Internal, }
171
172impl Visibility {
173 pub fn name(&self) -> &'static str {
174 match self {
175 Self::Public => "public",
176 Self::Private => "private",
177 Self::Protected => "protected",
178 Self::Internal => "internal",
179 }
180 }
181}
182
183#[derive(Debug, Clone, Serialize, Deserialize, Default)]
185pub struct Symbol {
186 pub name: String,
188 pub kind: SymbolKind,
190 pub signature: Option<String>,
192 pub docstring: Option<String>,
194 pub start_line: u32,
196 pub end_line: u32,
198 pub references: u32,
200 pub importance: f32,
202 pub parent: Option<String>,
204 pub visibility: Visibility,
206 pub calls: Vec<String>,
208 pub extends: Option<String>,
210 pub implements: Vec<String>,
212}
213
214impl Symbol {
215 pub fn new(name: impl Into<String>, kind: SymbolKind) -> Self {
217 Self {
218 name: name.into(),
219 kind,
220 signature: None,
221 docstring: None,
222 start_line: 0,
223 end_line: 0,
224 references: 0,
225 importance: 0.5,
226 parent: None,
227 visibility: Visibility::default(),
228 calls: Vec::new(),
229 extends: None,
230 implements: Vec::new(),
231 }
232 }
233
234 #[must_use]
236 pub fn line_count(&self) -> u32 {
237 if self.end_line >= self.start_line {
238 self.end_line - self.start_line + 1
239 } else {
240 1
241 }
242 }
243}
244
245impl fmt::Display for Symbol {
246 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
247 write!(
248 f,
249 "{}:{} (lines {}-{})",
250 self.kind.name(),
251 self.name,
252 self.start_line,
253 self.end_line
254 )
255 }
256}
257
258#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, Default)]
260pub enum SymbolKind {
261 #[default]
262 Function,
263 Method,
264 Class,
265 Interface,
266 Struct,
267 Enum,
268 Constant,
269 Variable,
270 Import,
271 Export,
272 TypeAlias,
273 Module,
274 Trait,
275 Macro,
276}
277
278impl SymbolKind {
279 #[must_use]
281 pub fn name(&self) -> &'static str {
282 match self {
283 Self::Function => "function",
284 Self::Method => "method",
285 Self::Class => "class",
286 Self::Interface => "interface",
287 Self::Struct => "struct",
288 Self::Enum => "enum",
289 Self::Constant => "constant",
290 Self::Variable => "variable",
291 Self::Import => "import",
292 Self::Export => "export",
293 Self::TypeAlias => "type",
294 Self::Module => "module",
295 Self::Trait => "trait",
296 Self::Macro => "macro",
297 }
298 }
299
300 #[must_use]
302 #[allow(clippy::should_implement_trait)]
303 pub fn from_str(s: &str) -> Option<Self> {
304 match s.to_lowercase().as_str() {
305 "function" => Some(Self::Function),
306 "method" => Some(Self::Method),
307 "class" => Some(Self::Class),
308 "interface" => Some(Self::Interface),
309 "struct" => Some(Self::Struct),
310 "enum" => Some(Self::Enum),
311 "constant" => Some(Self::Constant),
312 "variable" => Some(Self::Variable),
313 "import" => Some(Self::Import),
314 "export" => Some(Self::Export),
315 "type" | "typealias" => Some(Self::TypeAlias),
316 "module" => Some(Self::Module),
317 "trait" => Some(Self::Trait),
318 "macro" => Some(Self::Macro),
319 _ => None,
320 }
321 }
322}
323
324impl std::str::FromStr for SymbolKind {
325 type Err = ();
326
327 fn from_str(s: &str) -> Result<Self, Self::Err> {
328 SymbolKind::from_str(s).ok_or(())
329 }
330}
331
332impl fmt::Display for SymbolKind {
333 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
334 write!(f, "{}", self.name())
335 }
336}
337
338#[derive(Debug, Clone, Default, Serialize, Deserialize)]
340pub struct RepoMetadata {
341 pub total_files: u32,
343 pub total_lines: u64,
345 pub total_tokens: TokenCounts,
347 pub languages: Vec<LanguageStats>,
349 pub framework: Option<String>,
351 pub description: Option<String>,
353 pub branch: Option<String>,
355 pub commit: Option<String>,
357 pub directory_structure: Option<String>,
359 pub external_dependencies: Vec<String>,
361 pub git_history: Option<GitHistory>,
363}
364
365#[derive(Debug, Clone, Serialize, Deserialize)]
367pub struct LanguageStats {
368 pub language: String,
370 pub files: u32,
372 pub lines: u64,
374 pub percentage: f32,
376}
377
378#[derive(Debug, Clone, Serialize, Deserialize)]
380pub struct GitCommitInfo {
381 pub hash: String,
383 pub short_hash: String,
385 pub author: String,
387 pub date: String,
389 pub message: String,
391}
392
393#[derive(Debug, Clone, Default, Serialize, Deserialize)]
395pub struct GitHistory {
396 pub commits: Vec<GitCommitInfo>,
398 pub changed_files: Vec<GitChangedFile>,
400}
401
402#[derive(Debug, Clone, Serialize, Deserialize)]
404pub struct GitChangedFile {
405 pub path: String,
407 pub status: String,
409 #[serde(skip_serializing_if = "Option::is_none")]
411 pub diff_content: Option<String>,
412}
413
414#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Serialize, Deserialize)]
416pub enum CompressionLevel {
417 None,
419 Minimal,
421 #[default]
423 Balanced,
424 Aggressive,
426 Extreme,
428 Focused,
430 Semantic,
444}
445
446impl CompressionLevel {
447 pub fn expected_reduction(&self) -> u8 {
454 match self {
455 Self::None => 0,
456 Self::Minimal => 15,
457 Self::Balanced => 35,
458 Self::Aggressive => 60,
459 Self::Extreme => 80,
460 Self::Focused => 75,
461 Self::Semantic => 65,
464 }
465 }
466
467 pub fn description(&self) -> &'static str {
469 match self {
470 Self::None => "No compression - original content preserved",
471 Self::Minimal => "Remove empty lines, trim whitespace",
472 Self::Balanced => "Remove comments, normalize whitespace",
473 Self::Aggressive => "Remove docstrings, keep signatures only",
474 Self::Extreme => "Key symbols only - minimal context",
475 Self::Focused => "Focused symbols with small surrounding context",
476 Self::Semantic => "Semantic chunking with intelligent sampling",
477 }
478 }
479
480 #[allow(clippy::should_implement_trait)]
485 pub fn from_str(s: &str) -> Option<Self> {
486 match s.to_lowercase().as_str() {
487 "none" => Some(Self::None),
488 "minimal" => Some(Self::Minimal),
489 "balanced" => Some(Self::Balanced),
490 "aggressive" => Some(Self::Aggressive),
491 "extreme" => Some(Self::Extreme),
492 "focused" => Some(Self::Focused),
493 "semantic" => Some(Self::Semantic),
494 _ => None,
495 }
496 }
497
498 pub fn name(&self) -> &'static str {
500 match self {
501 Self::None => "none",
502 Self::Minimal => "minimal",
503 Self::Balanced => "balanced",
504 Self::Aggressive => "aggressive",
505 Self::Extreme => "extreme",
506 Self::Focused => "focused",
507 Self::Semantic => "semantic",
508 }
509 }
510
511 pub fn all() -> &'static [Self] {
513 &[
514 Self::None,
515 Self::Minimal,
516 Self::Balanced,
517 Self::Aggressive,
518 Self::Extreme,
519 Self::Focused,
520 Self::Semantic,
521 ]
522 }
523}
524
525impl std::str::FromStr for CompressionLevel {
526 type Err = ();
527
528 fn from_str(s: &str) -> Result<Self, Self::Err> {
529 CompressionLevel::from_str(s).ok_or(())
530 }
531}
532
533#[cfg(test)]
534mod tests {
535 use super::*;
536
537 #[test]
538 fn test_repository_new() {
539 let repo = Repository::new("test", "/tmp/test");
540 assert_eq!(repo.name, "test");
541 assert!(repo.files.is_empty());
542 }
543
544 #[test]
545 fn test_repository_total_tokens() {
546 let mut repo = Repository::new("test", "/tmp/test");
547 let mut file1 = RepoFile::new("/tmp/test/a.rs", "a.rs");
548 file1.token_count.set(TokenizerModel::Claude, 100);
549 let mut file2 = RepoFile::new("/tmp/test/b.rs", "b.rs");
550 file2.token_count.set(TokenizerModel::Claude, 200);
551 repo.files.push(file1);
552 repo.files.push(file2);
553 assert_eq!(repo.total_tokens(TokenizerModel::Claude), 300);
554 }
555
556 #[test]
557 fn test_repository_files_by_language() {
558 let mut repo = Repository::new("test", "/tmp/test");
559 let mut file1 = RepoFile::new("/tmp/test/a.rs", "a.rs");
560 file1.language = Some("rust".to_owned());
561 let mut file2 = RepoFile::new("/tmp/test/b.py", "b.py");
562 file2.language = Some("python".to_owned());
563 let mut file3 = RepoFile::new("/tmp/test/c.rs", "c.rs");
564 file3.language = Some("rust".to_owned());
565 repo.files.push(file1);
566 repo.files.push(file2);
567 repo.files.push(file3);
568
569 let rust_files = repo.files_by_language("rust");
570 assert_eq!(rust_files.len(), 2);
571 let python_files = repo.files_by_language("python");
572 assert_eq!(python_files.len(), 1);
573 let go_files = repo.files_by_language("go");
574 assert_eq!(go_files.len(), 0);
575 }
576
577 #[test]
578 fn test_repository_files_by_importance() {
579 let mut repo = Repository::new("test", "/tmp/test");
580 let mut file1 = RepoFile::new("/tmp/test/a.rs", "a.rs");
581 file1.importance = 0.3;
582 let mut file2 = RepoFile::new("/tmp/test/b.rs", "b.rs");
583 file2.importance = 0.9;
584 let mut file3 = RepoFile::new("/tmp/test/c.rs", "c.rs");
585 file3.importance = 0.6;
586 repo.files.push(file1);
587 repo.files.push(file2);
588 repo.files.push(file3);
589
590 let sorted = repo.files_by_importance();
591 assert_eq!(sorted[0].relative_path, "b.rs");
592 assert_eq!(sorted[1].relative_path, "c.rs");
593 assert_eq!(sorted[2].relative_path, "a.rs");
594 }
595
596 #[test]
597 fn test_repository_display() {
598 let mut repo = Repository::new("my-project", "/tmp/my-project");
599 repo.metadata.total_files = 42;
600 repo.metadata.total_lines = 1000;
601 let display = format!("{}", repo);
602 assert!(display.contains("my-project"));
603 assert!(display.contains("42 files"));
604 assert!(display.contains("1000 lines"));
605 }
606
607 #[test]
608 fn test_repo_file_new() {
609 let file = RepoFile::new("/tmp/test/src/main.rs", "src/main.rs");
610 assert_eq!(file.relative_path, "src/main.rs");
611 assert!(file.language.is_none());
612 assert_eq!(file.importance, 0.5);
613 }
614
615 #[test]
616 fn test_repo_file_extension() {
617 let file = RepoFile::new("/tmp/test/main.rs", "main.rs");
618 assert_eq!(file.extension(), Some("rs"));
619
620 let file_no_ext = RepoFile::new("/tmp/test/Makefile", "Makefile");
621 assert_eq!(file_no_ext.extension(), None);
622 }
623
624 #[test]
625 fn test_repo_file_filename() {
626 let file = RepoFile::new("/tmp/test/src/main.rs", "src/main.rs");
627 assert_eq!(file.filename(), "main.rs");
628 }
629
630 #[test]
631 fn test_repo_file_display() {
632 let mut file = RepoFile::new("/tmp/test/main.rs", "main.rs");
633 file.language = Some("rust".to_owned());
634 file.token_count.claude = 150;
635 let display = format!("{}", file);
636 assert!(display.contains("main.rs"));
637 assert!(display.contains("rust"));
638 assert!(display.contains("150"));
639 }
640
641 #[test]
642 fn test_repo_file_display_unknown_language() {
643 let file = RepoFile::new("/tmp/test/data.xyz", "data.xyz");
644 let display = format!("{}", file);
645 assert!(display.contains("unknown"));
646 }
647
648 #[test]
649 fn test_token_counts() {
650 let mut counts = TokenCounts::default();
651 counts.set(TokenizerModel::Claude, 100);
652 assert_eq!(counts.get(TokenizerModel::Claude), 100);
653 }
654
655 #[test]
656 fn test_symbol_new() {
657 let sym = Symbol::new("my_function", SymbolKind::Function);
658 assert_eq!(sym.name, "my_function");
659 assert_eq!(sym.kind, SymbolKind::Function);
660 assert_eq!(sym.importance, 0.5);
661 assert!(sym.signature.is_none());
662 assert!(sym.calls.is_empty());
663 }
664
665 #[test]
666 fn test_symbol_line_count() {
667 let mut sym = Symbol::new("test", SymbolKind::Function);
668 sym.start_line = 10;
669 sym.end_line = 20;
670 assert_eq!(sym.line_count(), 11);
671 }
672
673 #[test]
674 fn test_symbol_line_count_single_line() {
675 let mut sym = Symbol::new("test", SymbolKind::Variable);
676 sym.start_line = 5;
677 sym.end_line = 5;
678 assert_eq!(sym.line_count(), 1);
679 }
680
681 #[test]
682 fn test_symbol_line_count_inverted() {
683 let mut sym = Symbol::new("test", SymbolKind::Variable);
684 sym.start_line = 20;
685 sym.end_line = 10; assert_eq!(sym.line_count(), 1);
687 }
688
689 #[test]
690 fn test_symbol_display() {
691 let mut sym = Symbol::new("calculate", SymbolKind::Function);
692 sym.start_line = 10;
693 sym.end_line = 25;
694 let display = format!("{}", sym);
695 assert!(display.contains("function"));
696 assert!(display.contains("calculate"));
697 assert!(display.contains("10-25"));
698 }
699
700 #[test]
701 fn test_symbol_kind_name() {
702 assert_eq!(SymbolKind::Function.name(), "function");
703 assert_eq!(SymbolKind::Method.name(), "method");
704 assert_eq!(SymbolKind::Class.name(), "class");
705 assert_eq!(SymbolKind::Interface.name(), "interface");
706 assert_eq!(SymbolKind::Struct.name(), "struct");
707 assert_eq!(SymbolKind::Enum.name(), "enum");
708 assert_eq!(SymbolKind::Constant.name(), "constant");
709 assert_eq!(SymbolKind::Variable.name(), "variable");
710 assert_eq!(SymbolKind::Import.name(), "import");
711 assert_eq!(SymbolKind::Export.name(), "export");
712 assert_eq!(SymbolKind::TypeAlias.name(), "type");
713 assert_eq!(SymbolKind::Module.name(), "module");
714 assert_eq!(SymbolKind::Trait.name(), "trait");
715 assert_eq!(SymbolKind::Macro.name(), "macro");
716 }
717
718 #[test]
719 fn test_symbol_kind_from_str() {
720 assert_eq!(SymbolKind::from_str("function"), Some(SymbolKind::Function));
721 assert_eq!(SymbolKind::from_str("method"), Some(SymbolKind::Method));
722 assert_eq!(SymbolKind::from_str("class"), Some(SymbolKind::Class));
723 assert_eq!(SymbolKind::from_str("interface"), Some(SymbolKind::Interface));
724 assert_eq!(SymbolKind::from_str("struct"), Some(SymbolKind::Struct));
725 assert_eq!(SymbolKind::from_str("enum"), Some(SymbolKind::Enum));
726 assert_eq!(SymbolKind::from_str("constant"), Some(SymbolKind::Constant));
727 assert_eq!(SymbolKind::from_str("variable"), Some(SymbolKind::Variable));
728 assert_eq!(SymbolKind::from_str("import"), Some(SymbolKind::Import));
729 assert_eq!(SymbolKind::from_str("export"), Some(SymbolKind::Export));
730 assert_eq!(SymbolKind::from_str("type"), Some(SymbolKind::TypeAlias));
731 assert_eq!(SymbolKind::from_str("typealias"), Some(SymbolKind::TypeAlias));
732 assert_eq!(SymbolKind::from_str("module"), Some(SymbolKind::Module));
733 assert_eq!(SymbolKind::from_str("trait"), Some(SymbolKind::Trait));
734 assert_eq!(SymbolKind::from_str("macro"), Some(SymbolKind::Macro));
735 assert_eq!(SymbolKind::from_str("FUNCTION"), Some(SymbolKind::Function));
737 assert_eq!(SymbolKind::from_str("Class"), Some(SymbolKind::Class));
738 assert_eq!(SymbolKind::from_str("unknown"), None);
740 assert_eq!(SymbolKind::from_str(""), None);
741 }
742
743 #[test]
744 fn test_symbol_kind_std_from_str() {
745 assert_eq!("function".parse::<SymbolKind>(), Ok(SymbolKind::Function));
746 assert_eq!("class".parse::<SymbolKind>(), Ok(SymbolKind::Class));
747 assert!("invalid".parse::<SymbolKind>().is_err());
748 }
749
750 #[test]
751 fn test_symbol_kind_display() {
752 assert_eq!(format!("{}", SymbolKind::Function), "function");
753 assert_eq!(format!("{}", SymbolKind::Class), "class");
754 }
755
756 #[test]
757 fn test_visibility_name() {
758 assert_eq!(Visibility::Public.name(), "public");
759 assert_eq!(Visibility::Private.name(), "private");
760 assert_eq!(Visibility::Protected.name(), "protected");
761 assert_eq!(Visibility::Internal.name(), "internal");
762 }
763
764 #[test]
765 fn test_visibility_default() {
766 let vis = Visibility::default();
767 assert_eq!(vis, Visibility::Public);
768 }
769
770 #[test]
771 fn test_language_stats() {
772 let stats =
773 LanguageStats { language: "rust".to_owned(), files: 10, lines: 5000, percentage: 45.5 };
774 assert_eq!(stats.language, "rust");
775 assert_eq!(stats.files, 10);
776 assert_eq!(stats.lines, 5000);
777 assert!((stats.percentage - 45.5).abs() < f32::EPSILON);
778 }
779
780 #[test]
781 fn test_git_commit_info() {
782 let commit = GitCommitInfo {
783 hash: "abc123def456".to_owned(),
784 short_hash: "abc123d".to_owned(),
785 author: "Test Author".to_owned(),
786 date: "2025-01-01".to_owned(),
787 message: "Test commit".to_owned(),
788 };
789 assert_eq!(commit.hash, "abc123def456");
790 assert_eq!(commit.short_hash, "abc123d");
791 assert_eq!(commit.author, "Test Author");
792 }
793
794 #[test]
795 fn test_git_changed_file() {
796 let changed = GitChangedFile {
797 path: "src/main.rs".to_owned(),
798 status: "M".to_owned(),
799 diff_content: Some("+new line".to_owned()),
800 };
801 assert_eq!(changed.path, "src/main.rs");
802 assert_eq!(changed.status, "M");
803 assert!(changed.diff_content.is_some());
804 }
805
806 #[test]
807 fn test_git_history_default() {
808 let history = GitHistory::default();
809 assert!(history.commits.is_empty());
810 assert!(history.changed_files.is_empty());
811 }
812
813 #[test]
814 fn test_repo_metadata_default() {
815 let meta = RepoMetadata::default();
816 assert_eq!(meta.total_files, 0);
817 assert_eq!(meta.total_lines, 0);
818 assert!(meta.languages.is_empty());
819 assert!(meta.framework.is_none());
820 assert!(meta.branch.is_none());
821 }
822
823 #[test]
824 fn test_compression_level_from_str() {
825 assert_eq!(CompressionLevel::from_str("none"), Some(CompressionLevel::None));
826 assert_eq!(CompressionLevel::from_str("minimal"), Some(CompressionLevel::Minimal));
827 assert_eq!(CompressionLevel::from_str("balanced"), Some(CompressionLevel::Balanced));
828 assert_eq!(CompressionLevel::from_str("aggressive"), Some(CompressionLevel::Aggressive));
829 assert_eq!(CompressionLevel::from_str("extreme"), Some(CompressionLevel::Extreme));
830 assert_eq!(CompressionLevel::from_str("focused"), Some(CompressionLevel::Focused));
831 assert_eq!(CompressionLevel::from_str("semantic"), Some(CompressionLevel::Semantic));
832
833 assert_eq!(CompressionLevel::from_str("SEMANTIC"), Some(CompressionLevel::Semantic));
835 assert_eq!(CompressionLevel::from_str("Balanced"), Some(CompressionLevel::Balanced));
836
837 assert_eq!(CompressionLevel::from_str("unknown"), None);
839 assert_eq!(CompressionLevel::from_str(""), None);
840 }
841
842 #[test]
843 fn test_compression_level_std_from_str() {
844 assert_eq!("balanced".parse::<CompressionLevel>(), Ok(CompressionLevel::Balanced));
845 assert!("invalid".parse::<CompressionLevel>().is_err());
846 }
847
848 #[test]
849 fn test_compression_level_name() {
850 assert_eq!(CompressionLevel::None.name(), "none");
851 assert_eq!(CompressionLevel::Semantic.name(), "semantic");
852 }
853
854 #[test]
855 fn test_compression_level_expected_reduction() {
856 assert_eq!(CompressionLevel::None.expected_reduction(), 0);
857 assert_eq!(CompressionLevel::Minimal.expected_reduction(), 15);
858 assert_eq!(CompressionLevel::Balanced.expected_reduction(), 35);
859 assert_eq!(CompressionLevel::Aggressive.expected_reduction(), 60);
860 assert_eq!(CompressionLevel::Extreme.expected_reduction(), 80);
861 assert_eq!(CompressionLevel::Focused.expected_reduction(), 75);
862 assert_eq!(CompressionLevel::Semantic.expected_reduction(), 65);
863 }
864
865 #[test]
866 fn test_compression_level_description() {
867 for level in CompressionLevel::all() {
869 assert!(!level.description().is_empty());
870 }
871 }
872
873 #[test]
874 fn test_compression_level_all() {
875 let all = CompressionLevel::all();
876 assert_eq!(all.len(), 7);
877 assert!(all.contains(&CompressionLevel::Semantic));
878 }
879
880 #[test]
881 fn test_compression_level_default() {
882 let level = CompressionLevel::default();
883 assert_eq!(level, CompressionLevel::Balanced);
884 }
885}