}
impl Settings {
+ pub fn with_cc(mut self, cc: CC, style: NumberStyle) -> Self {
+ self.ccs[cc] = Some(Box::new(style));
+ self
+ }
fn number_style(&self, type_: Type) -> &NumberStyle {
static DEFAULT: LazyLock<NumberStyle> =
LazyLock::new(|| NumberStyle::new("", "", Decimal::Dot, None, false));
let mut s = String::new();
let mut quote = false;
for c in iter {
- if c == '\'' {
+ if c == '\'' && !quote {
quote = true;
+ } else if c == grouping && !quote {
+ break;
} else {
- if c == grouping && !quote {
- break;
- }
s.push(c);
quote = false;
}
use crate::{
dictionary::Value,
- format::{AbstractFormat, Format, Settings, UncheckedFormat},
+ format::{AbstractFormat, Format, NumberStyle, Settings, UncheckedFormat, CC},
lex::{
scan::StringScanner,
segment::Syntax,
.join("src/format/testdata")
.join(name);
let input = BufReader::new(File::open(&filename).unwrap());
- let settings = Settings::default();
+ let settings = Settings::default()
+ .with_cc(CC::A, ",,,".parse().unwrap())
+ .with_cc(CC::B, "-,[[[,]]],-".parse().unwrap())
+ .with_cc(CC::C, "((,[,],))".parse().unwrap())
+ .with_cc(CC::D, ",XXX,,-".parse().unwrap())
+ .with_cc(CC::E, ",,YYY,-".parse().unwrap());
let mut value = 0.0;
let mut value_name = String::new();
for (line_number, line) in input.lines().map(|r| r.unwrap()).enumerate() {
let expected = tokens[2].as_string().unwrap();
let actual = Value::Number(Some(value))
.display(format, UTF_8)
+ .with_settings(&settings)
.to_string();
assert_eq!(
expected,
fn z() {
test("z.txt");
}
+
+ #[test]
+ fn cca() {
+ test("cca.txt");
+ }
+
+ #[test]
+ fn ccb() {
+ test("ccb.txt");
+ }
+
+ #[test]
+ fn ccc() {
+ test("ccc.txt");
+ }
+
+ #[test]
+ fn ccd() {
+ test("ccd.txt");
+ }
+
+ #[test]
+ fn cce() {
+ test("cce.txt");
+ }
}