Skip to content

Commit bd4fa54

Browse files
committed
refactor: Remove obsolete test cases and improve test file path handling
1 parent 1445e69 commit bd4fa54

3 files changed

Lines changed: 42 additions & 49 deletions

File tree

kiru-core/src/bytes_chunker.rs

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -149,30 +149,6 @@ impl Chunker for BytesChunker {
149149
#[cfg(test)]
150150
mod tests {
151151
use super::*;
152-
use crate::stream::FileUtf8BlockReader;
153-
154-
const FILE_PATH: &str = "../../test-data/realistic-1.0mb.txt";
155-
156-
#[test]
157-
fn test_string_buffer_compaction() {
158-
let reader = FileUtf8BlockReader::new(FILE_PATH, 1024 * 8).unwrap();
159-
160-
let mut string_buffer = StringBuffer::new(reader, 1024 * 16);
161-
162-
while !string_buffer.done {
163-
let content = string_buffer.buffer();
164-
let content_len = content.len();
165-
let can = content.is_char_boundary(content_len - 10);
166-
if can {
167-
string_buffer.set_position(content_len - 10);
168-
assert!(
169-
string_buffer.position == 0,
170-
"Position should be updated correctly"
171-
);
172-
assert!(string_buffer.len() <= 10);
173-
}
174-
}
175-
}
176152

177153
#[test]
178154
fn test_bytes_chunker_stream() {

kiru-core/src/characters_chunker.rs

Lines changed: 32 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -178,31 +178,40 @@ impl Chunker for CharactersChunker {
178178

179179
#[cfg(test)]
180180
mod tests {
181-
use super::*;
182-
use crate::stream::FileUtf8BlockReader;
183181

184-
const FILE_PATH: &str = "../../test-data/realistic-1.0mb.txt";
182+
use super::*;
183+
// use std::path::PathBuf;
184+
// use crate::stream::FileUtf8BlockReader;
185+
186+
// fn get_test_file_path() -> String {
187+
// let manifest_dir = env!("CARGO_MANIFEST_DIR");
188+
// PathBuf::from(manifest_dir)
189+
// .join("../test-data/realistic-1.0mb.txt")
190+
// .to_string_lossy()
191+
// .into_owned()
192+
// }
193+
194+
// #[test]
195+
// fn test_string_buffer_compaction() {
196+
// let reader = FileUtf8BlockReader::new(get_test_file_path().as_str(), 1024 * 8).unwrap();
197+
198+
// let mut string_buffer = StringBuffer::new(reader, 1024 * 16);
199+
200+
// while !string_buffer.done {
201+
// let content = string_buffer.buffer();
202+
// let content_len = content.len();
203+
// let can = content.is_char_boundary(content_len - 10);
204+
// if can {
205+
// string_buffer.set_position(content_len - 10);
206+
// assert!(
207+
// string_buffer.position == 0,
208+
// "Position should be updated correctly"
209+
// );
210+
// assert!(string_buffer.len() <= 10);
211+
// }
212+
// }
213+
// }
185214

186-
#[test]
187-
fn test_string_buffer_compaction() {
188-
let reader = FileUtf8BlockReader::new(FILE_PATH, 1024 * 8).unwrap();
189-
190-
let mut string_buffer = StringBuffer::new(reader, 1024 * 16);
191-
192-
while !string_buffer.done {
193-
let content = string_buffer.buffer();
194-
let content_len = content.len();
195-
let can = content.is_char_boundary(content_len - 10);
196-
if can {
197-
string_buffer.set_position(content_len - 10);
198-
assert!(
199-
string_buffer.position == 0,
200-
"Position should be updated correctly"
201-
);
202-
assert!(string_buffer.len() <= 10);
203-
}
204-
}
205-
}
206215
#[test]
207216
fn test_characters_chunker_stream() {
208217
// let reader = FileUtf8BlockReader::new(FILE_PATH, 1024 * 8).unwrap();

kiru-core/src/stream.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,15 +228,23 @@ impl Iterator for StreamType {
228228

229229
#[cfg(test)]
230230
mod tests {
231+
use std::path::PathBuf;
232+
231233
use crate::{BytesChunker, Chunker};
232234

233235
use super::*;
234236

235-
const FILE_PATH: &str = "../..//test-data/realistic-1.0mb.txt";
237+
fn get_test_file_path() -> String {
238+
let manifest_dir = env!("CARGO_MANIFEST_DIR");
239+
PathBuf::from(manifest_dir)
240+
.join("../test-data/realistic-1.0mb.txt")
241+
.to_string_lossy()
242+
.into_owned()
243+
}
236244

237245
#[test]
238246
fn s() {
239-
let reader = FileUtf8BlockReader::new(FILE_PATH, 1024 * 64).unwrap();
247+
let reader = FileUtf8BlockReader::new(get_test_file_path().as_str(), 1024 * 64).unwrap();
240248

241249
let mut min_chunk_len = usize::MAX;
242250
let mut max_chunk_len = 0;

0 commit comments

Comments
 (0)