1
0
Fork 0
mirror of https://github.com/archtechx/todo-system.git synced 2026-08-06 04:24:04 +00:00

cargo fmt + fix clippy warnings

This commit is contained in:
Zykino 2026-07-30 00:25:09 +02:00
parent 6665e369bf
commit 16ec3a96e4
3 changed files with 694 additions and 483 deletions

View file

@ -1,14 +1,14 @@
use std::fs::canonicalize;
use std::path::PathBuf;
use clap::{Parser, ArgAction};
use crate::entries::Entry;
use crate::render::render_entries;
use crate::scan::{Stats, scan_dir, scan_todo_file, scan_readme_file, Exclude};
use crate::scan::{Exclude, Stats, scan_dir, scan_readme_file, scan_todo_file};
use clap::{ArgAction, Parser};
pub mod scan;
pub mod render;
pub mod entries;
pub mod render;
pub mod scan;
#[derive(Parser, Debug)]
#[command(author, version, about, long_about = None)]
@ -66,12 +66,12 @@ fn main() {
let mut path = root_dir.clone();
path.push(exclude);
if path.exists() {
if let Ok(realpath) = canonicalize(path) {
if path.exists()
&& let Ok(realpath) = canonicalize(path)
{
excludes.push(Exclude::Path(realpath));
}
}
}
let mut todos_path = root_dir.clone();
todos_path.push(&args.todos);
@ -100,9 +100,9 @@ fn main() {
if args.verbose > 0 {
eprint!("\n\n");
stats.print();
eprintln!("Paths ({}): {:?}", &paths.len(), &paths);
eprintln!("Excludes ({}): {:?}", &excludes.len(), &excludes);
eprintln!("todo.md: {:?}", &todos_path);
eprintln!("readme.md: {:?}", &readme_path);
eprintln!("Paths ({}): {:?}", paths.len(), paths);
eprintln!("Excludes ({}): {:?}", excludes.len(), excludes);
eprintln!("todo.md: {:?}", todos_path);
eprintln!("readme.md: {:?}", readme_path);
}
}

View file

@ -1,7 +1,7 @@
use std::io::Write;
use std::cmp::Ordering::{Equal, Greater, Less};
use std::collections::HashMap;
use std::io::Write;
use termcolor::{Color, ColorChoice, ColorSpec, StandardStream, WriteColor};
use std::cmp::Ordering::{Less, Equal, Greater};
use crate::entries::{Entry, EntryData};
@ -10,11 +10,20 @@ impl Entry {
let mut stdout = StandardStream::stdout(ColorChoice::Auto);
write_ansi(&mut stdout, Color::Ansi256(243), "- [ ] ", false);
let location = format!("{}:{}", self.location.file.to_string_lossy(), self.location.line);
let location = format!(
"{}:{}",
self.location.file.to_string_lossy(),
self.location.line
);
if ! self.text.is_empty() {
if !self.text.is_empty() {
write_ansi(&mut stdout, Color::Blue, self.text.as_str(), true);
write_ansi(&mut stdout, Color::Ansi256(243), format!(" ({})", location).as_str(), false);
write_ansi(
&mut stdout,
Color::Ansi256(243),
format!(" ({})", location).as_str(),
false,
);
} else {
write_ansi(&mut stdout, Color::Cyan, location.as_str(), true);
}
@ -23,13 +32,10 @@ impl Entry {
}
}
pub fn write_ansi(stdout: &mut StandardStream, color: Color, text: &str, bold: bool) {
stdout.set_color(
ColorSpec::new()
.set_fg(Some(color))
.set_bold(bold)
).unwrap();
stdout
.set_color(ColorSpec::new().set_fg(Some(color)).set_bold(bold))
.unwrap();
write!(stdout, "{text}").unwrap();
@ -46,21 +52,19 @@ pub fn render_entries(entries: Vec<Entry>) {
for entry in entries {
match entry.data {
EntryData::Priority(priority) => {
if ! priority_entries.contains_key(&priority) {
priority_entries.insert(priority, vec![]);
}
priority_entries.entry(priority).or_default();
let vec = priority_entries.get_mut(&priority).unwrap();
vec.push(entry);
},
}
EntryData::Category(ref category) => {
if ! category_entries.contains_key(category) {
if !category_entries.contains_key(category) {
category_entries.insert(category.clone(), vec![]);
}
let vec = category_entries.get_mut(category).unwrap();
vec.push(entry);
},
}
EntryData::Generic => {
generic_entries.push(entry);
}
@ -81,15 +85,24 @@ pub fn render_entries(entries: Vec<Entry>) {
// todo0 -> 0
// todo00 -> -1
// Therefore: 'todo0' + priority.abs() * '0'
str.push_str(String::from_utf8(vec![b'0'; priority.unsigned_abs()]).unwrap().as_str());
str.push_str(
String::from_utf8(vec![b'0'; priority.unsigned_abs()])
.unwrap()
.as_str(),
);
str
},
}
Equal => "todo0".to_string(),
Greater => format!("todo{}", priority),
};
write_ansi(&mut stdout, Color::Red, format!("## {}", &priority_notation).as_str(), true);
write_ansi(
&mut stdout,
Color::Red,
format!("## {}", priority_notation).as_str(),
true,
);
writeln!(stdout).unwrap();
for item in priority_entries.get(priority).unwrap() {
@ -103,7 +116,12 @@ pub fn render_entries(entries: Vec<Entry>) {
category_keys.sort_by(|a, b| a.partial_cmp(b).unwrap());
for category in category_keys {
write_ansi(&mut stdout, Color::Green, format!("## {}", &category).as_str(), true);
write_ansi(
&mut stdout,
Color::Green,
format!("## {}", category).as_str(),
true,
);
writeln!(stdout).unwrap();
for item in category_entries.get(category).unwrap() {
@ -113,7 +131,7 @@ pub fn render_entries(entries: Vec<Entry>) {
println!();
}
if generic_entries.len() > 0 {
if !generic_entries.is_empty() {
write_ansi(&mut stdout, Color::White, "## Other", true);
writeln!(stdout).unwrap();

View file

@ -1,7 +1,7 @@
use std::io;
use glob::Pattern;
use std::fs::{self, canonicalize};
use std::io;
use std::path::{Path, PathBuf};
use glob::{Pattern};
const PRIORITY_CHARS: [char; 10] = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];
@ -45,7 +45,7 @@ impl Stats {
self.visited_file_count += 1;
if self.verbosity >= 3 {
eprintln!("[INFO] Visited file: {}", &file);
eprintln!("[INFO] Visited file: {}", file);
}
if self.verbosity >= 2 {
@ -57,7 +57,7 @@ impl Stats {
self.visited_folder_count += 1;
if self.verbosity >= 3 {
eprintln!("[INFO] Visited folder: {}", &folder);
eprintln!("[INFO] Visited folder: {}", folder);
}
if self.verbosity >= 2 {
@ -106,7 +106,9 @@ fn parse_priority(word: &str) -> Option<isize> {
/// Remove closing tags, comments, and whitespace
fn clean_line<'a>(line: &'a str, delimiter_word: &str) -> &'a str {
line.split_once(delimiter_word).unwrap().1
line.split_once(delimiter_word)
.unwrap()
.1
.trim()
.trim_end_matches("*/")
.trim_end_matches("-->")
@ -119,7 +121,7 @@ pub fn add_excludes_from_gitignore(base_dir: &PathBuf, excludes: &mut Vec<Exclud
let mut gitignore = base_dir.clone();
gitignore.push(".gitignore");
if ! gitignore.exists() {
if !gitignore.exists() {
return;
}
@ -148,11 +150,11 @@ pub fn add_excludes_from_gitignore(base_dir: &PathBuf, excludes: &mut Vec<Exclud
pattern.push(line.trim_end_matches("*/").trim_matches('/'));
if pattern.to_str().unwrap().contains('*') {
if let Some(str) = pattern.to_str() {
if let Ok(p) = Pattern::new(str) {
if let Some(str) = pattern.to_str()
&& let Ok(p) = Pattern::new(str)
{
excludes.push(Exclude::Glob(p));
}
}
} else {
excludes.push(Exclude::Path(pattern));
}
@ -188,7 +190,12 @@ pub fn scan_string(str: String, filename: PathBuf, entries: &mut Vec<Entry>) {
// Handles: `todo`, `TODO`, `todo:`, `TODO:`
// Also trims `"` and `'` to handle cases like `foo="bar todo"`
if word.to_lowercase().trim_end_matches('"').trim_end_matches('\'') == "todo" {
if word
.to_lowercase()
.trim_end_matches('"')
.trim_end_matches('\'')
== "todo"
{
entries.push(Entry {
text: text.to_string(),
location: Location {
@ -214,8 +221,9 @@ pub fn scan_string(str: String, filename: PathBuf, entries: &mut Vec<Entry>) {
continue;
}
if word.chars().any(|ch| PRIORITY_CHARS.contains(&ch)) {
if let Some(priority) = parse_priority(word) {
if word.chars().any(|ch| PRIORITY_CHARS.contains(&ch))
&& let Some(priority) = parse_priority(word)
{
entries.push(Entry {
text: text.to_string(),
location: Location {
@ -224,7 +232,6 @@ pub fn scan_string(str: String, filename: PathBuf, entries: &mut Vec<Entry>) {
},
data: EntryData::Priority(priority),
});
}
continue;
}
@ -240,7 +247,12 @@ pub fn scan_file(path: &Path, entries: &mut Vec<Entry>) -> io::Result<()> {
Ok(())
}
pub fn scan_dir(dir: &Path, entries: &mut Vec<Entry>, excludes: &mut Vec<Exclude>, stats: &mut Stats) -> io::Result<()> {
pub fn scan_dir(
dir: &Path,
entries: &mut Vec<Entry>,
excludes: &mut Vec<Exclude>,
stats: &mut Stats,
) -> io::Result<()> {
let mut gitignore = dir.to_path_buf().clone();
gitignore.push(".gitignore");
@ -264,7 +276,14 @@ pub fn scan_dir(dir: &Path, entries: &mut Vec<Entry>, excludes: &mut Vec<Exclude
let entry = entry?;
let path = entry.path();
if path.components().last().unwrap().as_os_str().to_string_lossy().starts_with('.') {
if path
.components()
.next_back()
.unwrap()
.as_os_str()
.to_string_lossy()
.starts_with('.')
{
continue;
}
@ -299,31 +318,37 @@ pub fn scan_todo_file(path: &Path, entries: &mut Vec<Entry>) -> io::Result<()> {
// If we are in an *unindented* code block, we ignore lines
// starting with # - they cannot be headings. Indented
// code blocks are irrelevant.
in_code_block = ! in_code_block;
in_code_block = !in_code_block;
continue;
}
// We need the line to start with # followed by spaces. So we cannot check just for '#'
// There's also no real need for any complex logic iterating over the line's characters,
// we can just check reasonable heading hierarchy like this. Anything else is unlikely.
if ! in_code_block && (false
if !in_code_block
&& (false
|| line.starts_with("# ")
|| line.starts_with("## ")
|| line.starts_with("### ")
|| line.starts_with("#### ")
|| line.starts_with("##### ")
) {
|| line.starts_with("##### "))
{
current_category = Some(line.split_once("# ").unwrap().1);
continue;
}
if ! line.trim_start().starts_with('-') {
if !line.trim_start().starts_with('-') {
continue;
}
for word in line.split_whitespace() {
if word.to_lowercase().trim_end_matches(':').starts_with("todo") && word.chars().any(|ch| PRIORITY_CHARS.contains(&ch)) {
if word
.to_lowercase()
.trim_end_matches(':')
.starts_with("todo")
&& word.chars().any(|ch| PRIORITY_CHARS.contains(&ch))
{
if let Some(priority) = parse_priority(word.trim_end_matches(':')) {
entries.push(Entry {
text: clean_line(line, word).to_string(),
@ -339,7 +364,11 @@ pub fn scan_todo_file(path: &Path, entries: &mut Vec<Entry>) -> io::Result<()> {
}
}
let text = line.trim_start().trim_start_matches("- [ ] ").trim_start_matches("- ").to_string();
let text = line
.trim_start()
.trim_start_matches("- [ ] ")
.trim_start_matches("- ")
.to_string();
if let Some(category) = current_category {
entries.push(Entry {
@ -381,38 +410,48 @@ pub fn scan_readme_file(path: &Path, entries: &mut Vec<Entry>) -> io::Result<()>
// If we are in an *unindented* code block, we ignore lines
// starting with # - they cannot be headings. Indented
// code blocks are irrelevant.
in_code_block = ! in_code_block;
in_code_block = !in_code_block;
continue;
}
// We need the line to start with # followed by spaces. So we cannot check just for '#'
// There's also no real need for any complex logic iterating over the line's characters,
// we can just check reasonable heading hierarchy like this. Anything else is unlikely.
if ! in_code_block && (false
if !in_code_block
&& (false
|| line.starts_with("# ")
|| line.starts_with("## ")
|| line.starts_with("### ")
|| line.starts_with("#### ")
|| line.starts_with("##### ")
) {
|| line.starts_with("##### "))
{
let section = line.split_once("# ").unwrap().1;
let cleaned_section = section.to_lowercase().trim_end_matches(':').trim().to_string();
let cleaned_section = section
.to_lowercase()
.trim_end_matches(':')
.trim()
.to_string();
in_todo_section = cleaned_section == "todo" || cleaned_section == "todos";
continue;
}
if ! in_todo_section {
if !in_todo_section {
continue;
}
if ! line.trim_start().starts_with('-') {
if !line.trim_start().starts_with('-') {
continue;
}
for word in line.split_whitespace() {
if word.to_lowercase().trim_end_matches(':').starts_with("todo") && word.chars().any(|ch| PRIORITY_CHARS.contains(&ch)) {
if word
.to_lowercase()
.trim_end_matches(':')
.starts_with("todo")
&& word.chars().any(|ch| PRIORITY_CHARS.contains(&ch))
{
if let Some(priority) = parse_priority(word.trim_end_matches(':')) {
entries.push(Entry {
text: clean_line(line, word).to_string(),
@ -430,7 +469,11 @@ pub fn scan_readme_file(path: &Path, entries: &mut Vec<Entry>) -> io::Result<()>
// README.md can only have priority entries and generic entries
entries.push(Entry {
text: line.trim_start().trim_start_matches("- [ ] ").trim_start_matches("- ").to_string(),
text: line
.trim_start()
.trim_start_matches("- [ ] ")
.trim_start_matches("- ")
.to_string(),
location: Location {
file: path.to_path_buf(),
line: line_num + 1,
@ -470,59 +513,77 @@ mod tests {
assert_eq!(6, entries.len());
assert_eq!(Entry {
assert_eq!(
Entry {
data: EntryData::Generic,
text: String::from("foo"),
location: Location {
file: path.clone(),
line: 4,
}
}, entries[0]);
},
entries[0]
);
assert_eq!(Entry {
assert_eq!(
Entry {
data: EntryData::Generic,
text: String::from("foo bar"),
location: Location {
file: path.clone(),
line: 5,
}
}, entries[1]);
},
entries[1]
);
assert_eq!(Entry {
assert_eq!(
Entry {
data: EntryData::Generic,
text: String::from("baz"),
location: Location {
file: path.clone(),
line: 8,
}
}, entries[2]);
},
entries[2]
);
assert_eq!(Entry {
assert_eq!(
Entry {
data: EntryData::Generic,
text: String::from("baz2"),
location: Location {
file: path.clone(),
line: 9,
}
}, entries[3]);
},
entries[3]
);
assert_eq!(Entry {
assert_eq!(
Entry {
data: EntryData::Generic,
text: String::from("baz2 todo"),
location: Location {
file: path.clone(),
line: 10,
}
}, entries[4]);
},
entries[4]
);
assert_eq!(Entry {
assert_eq!(
Entry {
data: EntryData::Generic,
text: String::from("foo2"),
location: Location {
file: path.clone(),
line: 11,
}
}, entries[5]);
},
entries[5]
);
}
#[test]
@ -548,70 +609,91 @@ mod tests {
scan_string(str.to_string(), path.clone(), &mut entries);
assert_eq!(7, entries.len());
assert_eq!(8, entries.len());
assert_eq!(Entry {
assert_eq!(
Entry {
data: EntryData::Category(String::from("foo")),
text: String::from(""),
location: Location {
file: path.clone(),
line: 4,
}
}, entries[0]);
},
entries[0]
);
assert_eq!(Entry {
assert_eq!(
Entry {
data: EntryData::Category(String::from("bar")),
text: String::from("abc def"),
location: Location {
file: path.clone(),
line: 5,
}
}, entries[1]);
},
entries[1]
);
assert_eq!(Entry {
assert_eq!(
Entry {
data: EntryData::Category(String::from("baz")),
text: String::from("x y"),
location: Location {
file: path.clone(),
line: 7,
}
}, entries[2]);
},
entries[2]
);
assert_eq!(Entry {
assert_eq!(
Entry {
data: EntryData::Category(String::from("baz2")),
text: String::from("a"),
location: Location {
file: path.clone(),
line: 9,
}
}, entries[3]);
},
entries[3]
);
assert_eq!(Entry {
assert_eq!(
Entry {
data: EntryData::Category(String::from("baz3")),
text: String::from(""),
location: Location {
file: path.clone(),
line: 10,
}
}, entries[4]);
},
entries[4]
);
assert_eq!(Entry {
assert_eq!(
Entry {
data: EntryData::Category(String::from("baz3")),
text: String::from("b"),
location: Location {
file: path.clone(),
line: 11,
}
}, entries[5]);
},
entries[5]
);
assert_eq!(Entry {
assert_eq!(
Entry {
data: EntryData::Category(String::from("baz3")),
text: String::from(""),
location: Location {
file: path.clone(),
line: 12,
}
}, entries[6]);
},
entries[6]
);
assert_eq!(
Entry {
@ -653,95 +735,125 @@ mod tests {
assert_eq!(10, entries.len());
assert_eq!(Entry {
assert_eq!(
Entry {
data: EntryData::Priority(-1),
text: String::from(""),
location: Location {
file: path.clone(),
line: 4,
}
}, entries[0]);
},
entries[0]
);
assert_eq!(Entry {
assert_eq!(
Entry {
data: EntryData::Priority(-2),
text: String::from("abc"),
location: Location {
file: path.clone(),
line: 5,
}
}, entries[1]);
},
entries[1]
);
assert_eq!(Entry {
assert_eq!(
Entry {
data: EntryData::Priority(0),
text: String::from("abc def"),
location: Location {
file: path.clone(),
line: 6,
}
}, entries[2]);
},
entries[2]
);
assert_eq!(Entry {
assert_eq!(
Entry {
data: EntryData::Priority(1),
text: String::from("foo"),
location: Location {
file: path.clone(),
line: 7,
}
}, entries[3]);
},
entries[3]
);
assert_eq!(Entry {
assert_eq!(
Entry {
data: EntryData::Priority(1),
text: String::from("x y"),
location: Location {
file: path.clone(),
line: 9,
}
}, entries[4]);
},
entries[4]
);
assert_eq!(Entry {
assert_eq!(
Entry {
data: EntryData::Priority(0),
text: String::from("bar"),
location: Location {
file: path.clone(),
line: 11,
}
}, entries[5]);
},
entries[5]
);
assert_eq!(Entry {
assert_eq!(
Entry {
data: EntryData::Priority(1),
text: String::from("a"),
location: Location {
file: path.clone(),
line: 12,
}
}, entries[6]);
},
entries[6]
);
assert_eq!(Entry {
assert_eq!(
Entry {
data: EntryData::Priority(2),
text: String::from(""),
location: Location {
file: path.clone(),
line: 13,
}
}, entries[7]);
},
entries[7]
);
assert_eq!(Entry {
assert_eq!(
Entry {
data: EntryData::Priority(3),
text: String::from("b"),
location: Location {
file: path.clone(),
line: 14,
}
}, entries[8]);
},
entries[8]
);
assert_eq!(Entry {
assert_eq!(
Entry {
data: EntryData::Priority(4),
text: String::from("b"),
location: Location {
file: path.clone(),
line: 15,
}
}, entries[9]);
},
entries[9]
);
}
#[test]
@ -756,95 +868,125 @@ mod tests {
assert_eq!(10, entries.len());
assert_eq!(Entry {
assert_eq!(
Entry {
data: EntryData::Category(String::from("types")),
text: String::from(""),
location: Location {
file: path.clone(),
line: 1,
}
}, entries[0]);
},
entries[0]
);
assert_eq!(Entry {
assert_eq!(
Entry {
data: EntryData::Category(String::from("types")),
text: String::from("add types"),
location: Location {
file: path.clone(),
line: 5,
}
}, entries[1]);
},
entries[1]
);
assert_eq!(Entry {
assert_eq!(
Entry {
data: EntryData::Priority(-2),
text: String::from(""),
location: Location {
file: path.clone(),
line: 10,
}
}, entries[2]);
},
entries[2]
);
assert_eq!(Entry {
assert_eq!(
Entry {
data: EntryData::Priority(-1),
text: String::from("add return typehint"),
location: Location {
file: path.clone(),
line: 14,
}
}, entries[3]);
},
entries[3]
);
assert_eq!(Entry {
assert_eq!(
Entry {
data: EntryData::Priority(0),
text: String::from("add name typehint"),
location: Location {
file: path.clone(),
line: 19,
}
}, entries[4]);
},
entries[4]
);
assert_eq!(Entry {
assert_eq!(
Entry {
data: EntryData::Priority(1),
text: String::from("add return typehint"),
location: Location {
file: path.clone(),
line: 23,
}
}, entries[5]);
},
entries[5]
);
assert_eq!(Entry {
assert_eq!(
Entry {
data: EntryData::Priority(2),
text: String::from("add return typehint"),
location: Location {
file: path.clone(),
line: 27,
}
}, entries[6]);
},
entries[6]
);
assert_eq!(Entry {
assert_eq!(
Entry {
data: EntryData::Generic,
text: String::from(""),
location: Location {
file: path.clone(),
line: 31,
}
}, entries[7]);
},
entries[7]
);
assert_eq!(Entry {
assert_eq!(
Entry {
data: EntryData::Generic,
text: String::from("generic todo 2"),
location: Location {
file: path.clone(),
line: 33,
}
}, entries[8]);
},
entries[8]
);
assert_eq!(Entry {
assert_eq!(
Entry {
data: EntryData::Generic,
text: String::from("generic todo 3"),
location: Location {
file: path.clone(),
line: 34,
}
}, entries[9]);
},
entries[9]
);
}
#[test]
@ -859,41 +1001,53 @@ mod tests {
assert_eq!(4, entries.len());
assert_eq!(Entry {
assert_eq!(
Entry {
data: EntryData::Generic,
text: String::from("todo!(\"generic\");"),
location: Location {
file: path.clone(),
line: 3,
}
}, entries[0]);
},
entries[0]
);
assert_eq!(Entry {
assert_eq!(
Entry {
data: EntryData::Generic,
text: String::from("todo!();"),
location: Location {
file: path.clone(),
line: 4,
}
}, entries[1]);
},
entries[1]
);
assert_eq!(Entry {
assert_eq!(
Entry {
data: EntryData::Generic,
text: String::from("todo!(\"@foo not category\");"),
location: Location {
file: path.clone(),
line: 5,
}
}, entries[2]);
},
entries[2]
);
assert_eq!(Entry {
assert_eq!(
Entry {
data: EntryData::Generic,
text: String::from("todo!(\"00 not priority\");"),
location: Location {
file: path.clone(),
line: 6,
}
}, entries[3]);
},
entries[3]
);
}
#[test]
@ -908,77 +1062,101 @@ mod tests {
assert_eq!(8, entries.len());
assert_eq!(Entry {
assert_eq!(
Entry {
data: EntryData::Generic,
text: String::from("generic foo"),
location: Location {
file: path.clone(),
line: 1,
}
}, entries[0]);
},
entries[0]
);
assert_eq!(Entry {
assert_eq!(
Entry {
data: EntryData::Generic,
text: String::from("generic bar"),
location: Location {
file: path.clone(),
line: 2,
}
}, entries[1]);
},
entries[1]
);
assert_eq!(Entry {
assert_eq!(
Entry {
data: EntryData::Priority(-1),
text: String::from("priority bar"),
location: Location {
file: path.clone(),
line: 3,
}
}, entries[2]);
},
entries[2]
);
assert_eq!(Entry {
assert_eq!(
Entry {
data: EntryData::Priority(0),
text: String::from("a"),
location: Location {
file: path.clone(),
line: 6,
}
}, entries[3]);
},
entries[3]
);
assert_eq!(Entry {
assert_eq!(
Entry {
data: EntryData::Category(String::from("High priority")),
text: String::from("foo"),
location: Location {
file: path.clone(),
line: 7,
}
}, entries[4]);
},
entries[4]
);
assert_eq!(Entry {
assert_eq!(
Entry {
data: EntryData::Category(String::from("High priority")),
text: String::from("bar"),
location: Location {
file: path.clone(),
line: 8,
}
}, entries[5]);
},
entries[5]
);
assert_eq!(Entry {
assert_eq!(
Entry {
data: EntryData::Category(String::from("Responsivity")),
text: String::from("abc"),
location: Location {
file: path.clone(),
line: 11,
}
}, entries[6]);
},
entries[6]
);
assert_eq!(Entry {
assert_eq!(
Entry {
data: EntryData::Category(String::from("Responsivity")),
text: String::from("def"),
location: Location {
file: path.clone(),
line: 12,
}
}, entries[7]);
},
entries[7]
);
}
#[test]
@ -993,49 +1171,64 @@ mod tests {
assert_eq!(5, entries.len());
assert_eq!(Entry {
assert_eq!(
Entry {
data: EntryData::Generic,
text: String::from("abc"),
location: Location {
file: path.clone(),
line: 19,
}
}, entries[0]);
},
entries[0]
);
assert_eq!(Entry {
assert_eq!(
Entry {
data: EntryData::Priority(0),
text: String::from("def"),
location: Location {
file: path.clone(),
line: 20,
}
}, entries[1]);
},
entries[1]
);
assert_eq!(Entry {
assert_eq!(
Entry {
data: EntryData::Priority(-1),
text: String::from("ghi"),
location: Location {
file: path.clone(),
line: 21,
}
}, entries[2]);
},
entries[2]
);
assert_eq!(Entry {
assert_eq!(
Entry {
data: EntryData::Generic,
text: String::from("bar"),
location: Location {
file: path.clone(),
line: 22,
}
}, entries[3]);
},
entries[3]
);
assert_eq!(Entry {
assert_eq!(
Entry {
data: EntryData::Generic,
text: String::from("baz"),
location: Location {
file: path.clone(),
line: 23,
}
}, entries[4]);
},
entries[4]
);
}
}