From 0e06422b3581c092f0b79e1e1e5fec8b0838583c Mon Sep 17 00:00:00 2001 From: mace Date: Sat, 29 Jul 2023 16:25:44 +0200 Subject: [PATCH] Fix some issues, reorgenize --- Cargo.lock | 292 ++++++++++++++++++++++++++++++++-------- Cargo.toml | 2 +- src/cli.yml | 37 ----- src/csv/args.rs | 20 +++ src/csv/compare.rs | 120 +++++++++++++++++ src/csv/mod.rs | 2 + src/lib.rs | 79 ----------- src/main.rs | 57 ++++---- target/.rustc_info.json | 2 +- tests/unit_test.rs | 24 ---- 10 files changed, 405 insertions(+), 230 deletions(-) delete mode 100644 src/cli.yml create mode 100644 src/csv/args.rs create mode 100644 src/csv/compare.rs create mode 100644 src/csv/mod.rs delete mode 100644 src/lib.rs delete mode 100644 tests/unit_test.rs diff --git a/Cargo.lock b/Cargo.lock index 5ea7ef5..c3d85c5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3,47 +3,113 @@ version = 3 [[package]] -name = "ansi_term" -version = "0.11.0" +name = "anstream" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" +checksum = "0ca84f3628370c59db74ee214b3263d58f9aadd9b4fe7e711fd87dc452b7f163" dependencies = [ - "winapi", + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is-terminal", + "utf8parse", ] [[package]] -name = "atty" -version = "0.2.14" +name = "anstyle" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +checksum = "3a30da5c5f2d5e72842e00bcb57657162cdabef0931f40e2deb9b4140440cecd" + +[[package]] +name = "anstyle-parse" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "938874ff5980b03a87c5524b3ae5b59cf99b1d6bc836848df7bc5ada9643c333" dependencies = [ - "hermit-abi", - "libc", - "winapi", + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b" +dependencies = [ + "windows-sys", +] + +[[package]] +name = "anstyle-wincon" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "180abfa45703aebe0093f79badacc01b8fd4ea2e35118747e5811127f926e188" +dependencies = [ + "anstyle", + "windows-sys", ] [[package]] name = "bitflags" -version = "1.2.1" +version = "2.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" +checksum = "630be753d4e58660abd17930c71b647fe46c27ea6b63cc59e1e3851406972e42" + +[[package]] +name = "cc" +version = "1.0.79" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" [[package]] name = "clap" -version = "2.33.3" +version = "4.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002" +checksum = "5fd304a20bff958a57f04c4e96a2e7594cc4490a0e809cbd48bb6437edaa452d" dependencies = [ - "ansi_term", - "atty", - "bitflags", - "strsim", - "textwrap", - "unicode-width", - "vec_map", - "yaml-rust", + "clap_builder", + "clap_derive", + "once_cell", ] +[[package]] +name = "clap_builder" +version = "4.3.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01c6a3f08f1fe5662a35cfe393aec09c4df95f60ee93b7556505260f75eee9e1" +dependencies = [ + "anstream", + "anstyle", + "clap_lex", + "strsim", +] + +[[package]] +name = "clap_derive" +version = "4.3.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "54a9bb5758fc5dfe728d1019941681eccaf0cf8a4189b692a0ee2f2ecf90a050" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "clap_lex" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2da6da31387c7e4ef160ffab6d5e7f00c42626fe39aea70a7b0f1773f7dd6c1b" + +[[package]] +name = "colorchoice" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" + [[package]] name = "csvcompare" version = "0.1.0" @@ -52,71 +118,189 @@ dependencies = [ ] [[package]] -name = "hermit-abi" -version = "0.1.19" +name = "errno" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" +checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a" dependencies = [ + "errno-dragonfly", + "libc", + "windows-sys", +] + +[[package]] +name = "errno-dragonfly" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" +dependencies = [ + "cc", "libc", ] [[package]] -name = "libc" -version = "0.2.98" +name = "heck" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "320cfe77175da3a483efed4bc0adc1968ca050b098ce4f2f1c13a56626128790" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" + +[[package]] +name = "hermit-abi" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b" + +[[package]] +name = "is-terminal" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" +dependencies = [ + "hermit-abi", + "rustix", + "windows-sys", +] + +[[package]] +name = "libc" +version = "0.2.147" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" + +[[package]] +name = "linux-raw-sys" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09fc20d2ca12cb9f044c93e3bd6d32d523e6e2ec3db4f7b2939cd99026ecd3f0" + +[[package]] +name = "once_cell" +version = "1.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" + +[[package]] +name = "proc-macro2" +version = "1.0.66" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50f3b39ccfb720540debaa0164757101c08ecb8d326b15358ce76a62c7e85965" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rustix" +version = "0.38.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a962918ea88d644592894bc6dc55acc6c0956488adcebbfb6e273506b7fd6e5" +dependencies = [ + "bitflags", + "errno", + "libc", + "linux-raw-sys", + "windows-sys", +] [[package]] name = "strsim" -version = "0.8.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] -name = "textwrap" -version = "0.11.0" +name = "syn" +version = "2.0.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" +checksum = "b60f673f44a8255b9c8c657daf66a596d435f2da81a555b06dc644d080ba45e0" dependencies = [ - "unicode-width", + "proc-macro2", + "quote", + "unicode-ident", ] [[package]] -name = "unicode-width" -version = "0.1.8" +name = "unicode-ident" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3" +checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c" [[package]] -name = "vec_map" -version = "0.8.2" +name = "utf8parse" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" +checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" [[package]] -name = "winapi" -version = "0.3.9" +name = "windows-sys" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", + "windows-targets", ] [[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" +name = "windows-targets" +version = "0.48.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" +checksum = "05d4b17490f70499f20b9e791dcf6a299785ce8af4d709018206dc5b4953e95f" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] [[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" +name = "windows_aarch64_gnullvm" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" [[package]] -name = "yaml-rust" -version = "0.3.5" +name = "windows_aarch64_msvc" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e66366e18dc58b46801afbf2ca7661a9f59cc8c5962c29892b6039b4f86fa992" +checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" + +[[package]] +name = "windows_i686_gnu" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" + +[[package]] +name = "windows_i686_msvc" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" diff --git a/Cargo.toml b/Cargo.toml index 046ccf6..639af31 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,4 +9,4 @@ authors = ["Mathias Rothenhäusler -about: Compares two csv files. -args: - - source: - short: s - long: source - value_name: FILE1 - help: Defines the base csv file - takes_value: true - required: true - - compared: - short: f - long: compare - value_name: FILE2 - help: Defines the csv file to compare - takes_value: true - required: true - - delimiter: - short: d - long: delimiter - help: Csv delimiter character - required: false - takes_value: true - - column: - short: c - long: column - help: CSV column to compare - required: true - takes_value: true - - output: - short: o - long: output - help: Filename to write the result set - required: false - takes_value: true \ No newline at end of file diff --git a/src/csv/args.rs b/src/csv/args.rs new file mode 100644 index 0000000..c1d1001 --- /dev/null +++ b/src/csv/args.rs @@ -0,0 +1,20 @@ +use clap::Parser; + +#[derive(Parser, Debug)] +#[command(author, version, about, long_about = None)] +pub struct MyArgs { + #[arg(name = "source")] // Define the argument without a short or long version + pub source: String, + + #[arg(name = "compare")] // Define the argument without a short or long version + pub compare: String, + + #[arg(short, long)] + pub column: usize, + + #[arg(short, long)] + pub output: Option, + + #[arg(short, long, default_value_t = ';'.to_string())] + pub delimiter: String, +} diff --git a/src/csv/compare.rs b/src/csv/compare.rs new file mode 100644 index 0000000..5cd9cb6 --- /dev/null +++ b/src/csv/compare.rs @@ -0,0 +1,120 @@ +use std::io::Write as IoWrite; +use std::{ + fs::File, + io::{BufRead, BufReader}, +}; + +use super::args::MyArgs; + +#[derive(Debug)] +pub struct Params { + delimiter: String, + source: String, + compared: String, + column: usize, + output: Option, +} + +impl Params { + pub fn new_from_matches(matches: MyArgs) -> Self { + Self { + delimiter: matches.delimiter, + source: matches.source, + compared: matches.compare, + column: matches.column, + output: { + let this = matches.output; + this.map(|x| x.to_string()) + }, + } + } + + pub fn delimiter(&self) -> &String { + &self.delimiter + } + + pub fn source(&self) -> &String { + &self.source + } + + pub fn compared(&self) -> &String { + &self.compared + } + + pub fn column(&self) -> usize { + self.column + } + + pub fn output_mut(&mut self) -> &Option { + &self.output + } +} + +pub struct CsvLine { + pub line: String, +} + +impl CsvLine { + pub fn new(line: String) -> Self { + Self { line } + } +} + +pub fn print_lines(vector: Vec) { + for line in vector.iter() { + println!("{}", line.line); + } +} + +pub fn write_to_file(filename: String, diff: Vec) { + let mut file = File::create(filename).unwrap(); + for line in diff.iter() { + writeln!(&mut file, "{}", line.line).unwrap(); + } +} + +pub fn compare(reader: BufReader, reader2: BufReader, params: &Params) -> Vec { + let vec1: Vec = reader + .lines() + .map(|line| { + let bla = line.unwrap(); + CsvLine::new(bla.to_string()) + }) + .collect(); + + let vec2: Vec = reader2 + .lines() + .map(|line| { + let bla = line.unwrap(); + CsvLine::new(bla.to_string()) + }) + .collect(); + + let mut diff: Vec = Vec::new(); + + find_diff(&vec1, &vec2, &mut diff, params); + find_diff(&vec2, &vec1, &mut diff, params); + + diff +} + +fn find_diff(vec1: &[CsvLine], vec2: &[CsvLine], diff: &mut Vec, params: &Params) { + for i in vec1.iter() { + let splitter: Vec<&str> = i.line.split(params.delimiter()).collect(); + let value = splitter[params.column]; + + let found = !matches!( + vec2.iter().position(|r| { + let splitter_b: Vec<&str> = r.line.split(params.delimiter()).collect(); + let search = splitter_b[params.column()]; + search == value + }), + None + ); + + if !found { + diff.push(CsvLine::new(i.line.parse().unwrap())); + } + } +} + diff --git a/src/csv/mod.rs b/src/csv/mod.rs new file mode 100644 index 0000000..0a10301 --- /dev/null +++ b/src/csv/mod.rs @@ -0,0 +1,2 @@ +pub mod compare; +pub mod args; diff --git a/src/lib.rs b/src/lib.rs deleted file mode 100644 index cb584bb..0000000 --- a/src/lib.rs +++ /dev/null @@ -1,79 +0,0 @@ -pub mod csv_compare { - use std::io::Write as IoWrite; - use std::{ - fs::File, - io::{BufRead, BufReader}, - }; - - use clap::ArgMatches; - pub struct Params { - delimiter: String, - source: String, - compared: String, - column: usize, - output: String, - } - - impl Params { - pub fn new_from_matches(matches: ArgMatches) -> Self { - Self { - delimiter: matches.value_of("delimiter").unwrap_or(";").to_string(), - source: matches.value_of("source").unwrap().to_string(), - compared: matches.value_of("compared").unwrap().to_string(), - column: matches.value_of("column").unwrap().parse().unwrap(), - output: matches.value_of("output").unwrap().to_string(), - } - } - - pub fn delimiter(&self) -> &String { - &self.delimiter - } - - pub fn source(&self) -> &String { - &self.source - } - - pub fn compared(&self) -> &String { - &self.compared - } - - pub fn output(&self) -> &String { - &self.output - } - - pub fn column(&self) -> usize { - self.column - } - } - - pub struct CsvLine { - pub line: String, - } - - impl CsvLine { - pub fn new(line: String) -> Self { - Self { line } - } - } - - pub fn load_vector(vector: &mut Vec, reader: BufReader) { - // Read the file line by line using the lines() iterator from std::io::BufRead. - for (_index, line) in reader.lines().enumerate() { - let line = line.unwrap(); - vector.push(CsvLine::new(line.to_string())); - } - } - - pub fn print_lines(vector: Vec) { - for line in vector.iter() { - println!("{}", line.line); - } - } - - pub fn write_to_file(params: Params, diff: Vec) { - let mut file = File::create(params.output).unwrap(); - for line in diff.iter() { - writeln!(&mut file, "{}", line.line).unwrap(); - } - } -} diff --git a/src/main.rs b/src/main.rs index 97ed956..1bdbec5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,47 +1,36 @@ -use clap::{load_yaml, App}; -use csvcompare::csv_compare::{load_vector, print_lines, write_to_file, CsvLine, Params}; - +mod csv; use std::fs::File; use std::io::BufReader; -fn main() { - let yaml = load_yaml!("cli.yml"); - let matches = App::from_yaml(yaml).get_matches(); - let params = Params::new_from_matches(matches); - let file = File::open(¶ms.source()).expect("Can't find source file"); - let file2 = File::open(¶ms.compared()).expect("Cant't find compared file"); +use clap::Parser; +use csv::compare; + +use crate::csv::compare::{Params, write_to_file, print_lines}; +use crate::csv::args::MyArgs; + + +fn main() { + let args = MyArgs::parse(); + + let mut params = Params::new_from_matches(args); + + let file = File::open(params.source()).expect("Can't find source file"); + let file2 = File::open(params.compared()).expect("Cant't find compared file"); let reader = BufReader::new(file); let reader2 = BufReader::new(file2); - let mut vec1: Vec = Vec::new(); - let mut vec2: Vec = Vec::new(); - let mut diff: Vec = Vec::new(); + let diff = compare::compare(reader, reader2, ¶ms); - load_vector(&mut vec1, reader); - load_vector(&mut vec2, reader2); + let option_string_ref = params.output_mut(); - for i in vec1.iter() { - let splitter: Vec<&str> = i.line.split(params.delimiter()).collect(); - let value = splitter[params.column()]; - - let found = !matches!( - vec2.iter().position(|r| { - let splitter_b: Vec<&str> = r.line.split(params.delimiter()).collect(); - let search = splitter_b[params.column()]; - search == value - }), - None - ); - - if !found { - diff.push(CsvLine::new(i.line.parse().unwrap())); - } - } - - if params.output().is_empty() == false { - write_to_file(params, diff); + // Now, check if the option is Some and dereference it to get the String + if let Some(string_ref) = option_string_ref { + // Clone the underlying String since process_string expects ownership + write_to_file(string_ref.clone(), diff); + // Alternatively, you can pass the ownership directly and consume the String + // process_string(string_ref); } else { print_lines(diff); } diff --git a/target/.rustc_info.json b/target/.rustc_info.json index c04bb3b..bea4f0d 100644 --- a/target/.rustc_info.json +++ b/target/.rustc_info.json @@ -1 +1 @@ -{"rustc_fingerprint":7489809454134039525,"outputs":{"15729799797837862367":{"success":true,"status":"","code":0,"stdout":"___\nlib___.rlib\nlib___.so\nlib___.so\nlib___.a\nlib___.so\n/home/mace/.rustup/toolchains/stable-x86_64-unknown-linux-gnu\noff\npacked\nunpacked\n___\ndebug_assertions\npanic=\"unwind\"\nproc_macro\ntarget_arch=\"x86_64\"\ntarget_endian=\"little\"\ntarget_env=\"gnu\"\ntarget_family=\"unix\"\ntarget_feature=\"fxsr\"\ntarget_feature=\"sse\"\ntarget_feature=\"sse2\"\ntarget_has_atomic=\"16\"\ntarget_has_atomic=\"32\"\ntarget_has_atomic=\"64\"\ntarget_has_atomic=\"8\"\ntarget_has_atomic=\"ptr\"\ntarget_os=\"linux\"\ntarget_pointer_width=\"64\"\ntarget_vendor=\"unknown\"\nunix\n","stderr":""},"4614504638168534921":{"success":true,"status":"","code":0,"stdout":"rustc 1.71.0 (8ede3aae2 2023-07-12)\nbinary: rustc\ncommit-hash: 8ede3aae28fe6e4d52b38157d7bfe0d3bceef225\ncommit-date: 2023-07-12\nhost: x86_64-unknown-linux-gnu\nrelease: 1.71.0\nLLVM version: 16.0.5\n","stderr":""}},"successes":{}} \ No newline at end of file +{"rustc_fingerprint":14916813341232703558,"outputs":{"4614504638168534921":{"success":true,"status":"","code":0,"stdout":"rustc 1.71.0 (8ede3aae2 2023-07-12)\nbinary: rustc\ncommit-hash: 8ede3aae28fe6e4d52b38157d7bfe0d3bceef225\ncommit-date: 2023-07-12\nhost: x86_64-unknown-linux-gnu\nrelease: 1.71.0\nLLVM version: 16.0.5\n","stderr":""},"1185988223601034215":{"success":true,"status":"","code":0,"stdout":"___\nlib___.rlib\nlib___.so\nlib___.so\nlib___.a\nlib___.so\n/home/mace/.rustup/toolchains/stable-x86_64-unknown-linux-gnu\noff\npacked\nunpacked\n___\ndebug_assertions\nfeature=\"cargo-clippy\"\npanic=\"unwind\"\nproc_macro\ntarget_arch=\"x86_64\"\ntarget_endian=\"little\"\ntarget_env=\"gnu\"\ntarget_family=\"unix\"\ntarget_feature=\"fxsr\"\ntarget_feature=\"sse\"\ntarget_feature=\"sse2\"\ntarget_has_atomic=\"16\"\ntarget_has_atomic=\"32\"\ntarget_has_atomic=\"64\"\ntarget_has_atomic=\"8\"\ntarget_has_atomic=\"ptr\"\ntarget_os=\"linux\"\ntarget_pointer_width=\"64\"\ntarget_vendor=\"unknown\"\nunix\n","stderr":""}},"successes":{}} \ No newline at end of file diff --git a/tests/unit_test.rs b/tests/unit_test.rs deleted file mode 100644 index 429cb7f..0000000 --- a/tests/unit_test.rs +++ /dev/null @@ -1,24 +0,0 @@ -#[cfg(test)] -mod tests { - use std::{fs::File, io::BufReader, path::Path}; - - use csvcompare::csv_compare::{load_vector, CsvLine}; - - fn get_reader() -> BufReader { - let path = Path::new("./assets/csv1.csv"); - assert!(path.is_file()); - let file = File::open(path); - match file { - Ok(_) => BufReader::new(file.unwrap()), - Err(_) => panic!("error, could not read file"), - } - } - - #[test] - fn test_load_vector() { - let reader = get_reader(); - let mut vec1: Vec = Vec::new(); - load_vector(&mut vec1, reader); - assert_eq!(3, vec1.len()); - } -}