Skip to content

Commit 10b944d

Browse files
authored
feat: add cross-format integration tests and CLI end-to-end tests (#42)
- Add tests/cross_format.rs with 45 integration tests covering: - All format pair roundtrips: JSON↔YAML, JSON↔TOML, JSON↔CSV, YAML↔TOML, YAML↔CSV, TOML↔CSV - Three-format chains: JSON→YAML→TOML→JSON, YAML→TOML→JSON→YAML, JSON→CSV→YAML→JSON, CSV→JSON→TOML→CSV - Format-specific limitations: TOML top-level array rejection, TOML null→string conversion, CSV nested object flattening, CSV type inference, TOML datetime→string - Unicode cross-format roundtrips - Large dataset (500 rows) cross-format roundtrips - 11 CLI end-to-end tests: json→yaml, yaml→json, json→toml, csv→json, json→csv, --formats flag, file output, stdin→stdout, unknown format error, --pretty flag, --compact flag - Fix CSV float serialization to preserve decimal point (87.0 not 87) Fixes #14
1 parent a005106 commit 10b944d

File tree

2 files changed

+864
-1
lines changed

2 files changed

+864
-1
lines changed

src/formats/csv.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,21 @@ fn csv_field_to_string(value: &Value) -> String {
206206
Value::Null => String::new(),
207207
Value::Bool(b) => b.to_string(),
208208
Value::Int(i) => i.to_string(),
209-
Value::Float(f) => f.to_string(),
209+
Value::Float(f) => {
210+
let s = f.to_string();
211+
// Ensure float representation always contains a decimal point
212+
// so that CSV type inference re-parses it as Float, not Int.
213+
if s.contains('.')
214+
|| s.contains('e')
215+
|| s.contains('E')
216+
|| s.contains("inf")
217+
|| s.contains("NaN")
218+
{
219+
s
220+
} else {
221+
format!("{s}.0")
222+
}
223+
}
210224
Value::String(s) => s.clone(),
211225
Value::Bytes(b) => format!("{b:?}"),
212226
Value::Array(_) | Value::Map(_) => {

0 commit comments

Comments
 (0)