1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
//! CSV parser conformance test corpus.
//!
//! This crate ships a fixed set of CSV files that exercise the tricky parts of
//! CSV parsing, each paired with the JSON its parse result should equal. Feed
//! every [`Sample::csv`] to your parser and assert the output matches
//! `Sample::json`, except for `location_coordinates`, whose masked phone field
//! and lone-object JSON cannot equal a correct parse. The crate parses nothing
//! itself. It hands you the raw bytes.
//!
//! The corpus covers quoting, commas inside quoted fields, escaped (doubled)
//! quotes, embedded LF and CRLF inside fields, empty quoted fields, multibyte
//! UTF-8, UTF-8 replacement bytes, and a JSON document stored in one cell.
//!
//! # Bytes, not strings
//!
//! [`Sample::csv`] and [`Sample::json`] are `&[u8]`. The bytes are returned
//! exactly as stored. CRLF stays CRLF. The `0xEF 0xBF 0xBD` replacement
//! sequences in `location_coordinates` stay put. Trailing newlines are kept or
//! omitted per file. No decoding, no normalization, no trimming.
//!
//! # Example
//!
//! ```
//! let samples = csv_spectrum::spectrum();
//! assert_eq!(samples.len(), 12);
//! assert_eq!(samples[0].name, "comma_in_quotes");
//!
//! // The first sample's quoted field holds a comma that must not split.
//! let csv = std::str::from_utf8(samples[0].csv).unwrap();
//! assert!(csv.contains("\"Anytown, WW\""));
//! ```
/// One corpus entry: a CSV input and the JSON its parse result should equal.
///
/// `csv` and `json` are raw bytes, stored verbatim. `name` is the shared base
/// name of the pair with no extension, for example `"comma_in_quotes"`.
///
/// [`SAMPLES`] is sorted by unique `name` values. For that table, the derived
/// `Ord` implementation gives the same order because `name` decides every
/// comparison.
/// Loads a CSV and its matching JSON from `fixtures/` by base name.
/// Every sample, in ascending order by name.
///
/// The order is fixed and observable. Downstream code may index by position.
pub const SAMPLES: = ;
/// Returns all 12 samples, in ascending order by name.
///
/// This borrows the static [`SAMPLES`] table. There is no allocation. The
/// slice supports `.len()`, indexing, `.iter()`, and `for s in spectrum()`.
///
/// # Example
///
/// ```
/// let samples = csv_spectrum::spectrum();
/// let names: Vec<_> = samples.iter().map(|s| s.name).collect();
/// assert_eq!(names[1], "empty");
/// ```