mirror of
https://github.com/rzmk/czv.git
synced 2025-12-19 00:09:24 +00:00
52 lines
1.2 KiB
Rust
52 lines
1.2 KiB
Rust
use czv_wasm;
|
|
use czv_wasm::count::{ColumnCountOptions, RowCountOptions};
|
|
use czv_wasm::Result;
|
|
use wasm_bindgen_test::*;
|
|
wasm_bindgen_test::wasm_bindgen_test_configure!(run_in_browser);
|
|
|
|
#[test]
|
|
#[wasm_bindgen_test]
|
|
fn row_count_nonheader() -> Result<()> {
|
|
let options = RowCountOptions {
|
|
file_data: "fruit,price
|
|
apple,2.00
|
|
banana,1.50
|
|
strawberry,3.00"
|
|
.to_string(),
|
|
include_header_row: Some(false),
|
|
};
|
|
let result = czv_wasm::count::row_count(options)?;
|
|
assert_eq!(result, 3);
|
|
Ok(())
|
|
}
|
|
|
|
#[test]
|
|
#[wasm_bindgen_test]
|
|
fn row_count_header() -> Result<()> {
|
|
let options = RowCountOptions {
|
|
file_data: "fruit,price
|
|
apple,2.00
|
|
banana,1.50
|
|
strawberry,3.00"
|
|
.to_string(),
|
|
include_header_row: Some(true),
|
|
};
|
|
let result = czv_wasm::count::row_count(options)?;
|
|
assert_eq!(result, 4);
|
|
Ok(())
|
|
}
|
|
|
|
#[test]
|
|
#[wasm_bindgen_test]
|
|
fn column_count() -> Result<()> {
|
|
let options = ColumnCountOptions {
|
|
file_data: "fruit,price
|
|
apple,2.00
|
|
banana,1.50
|
|
strawberry,3.00"
|
|
.to_string(),
|
|
};
|
|
let result = czv_wasm::count::column_count(options)?;
|
|
assert_eq!(result, 2);
|
|
Ok(())
|
|
}
|