Skip to content

Commit 21dd9f2

Browse files
committed
Serialization with indents is broken. Replace these tests by no-indents serialization for now
Serialization will reworked soon and new tests will be written
1 parent 97a6be5 commit 21dd9f2

File tree

1 file changed

+28
-56
lines changed

1 file changed

+28
-56
lines changed

tests/serde-se.rs

Lines changed: 28 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,7 @@ fn newtype() {
136136
#[test]
137137
fn tuple() {
138138
let mut buffer = Vec::new();
139-
let mut ser =
140-
Serializer::with_root(Writer::new_with_indent(&mut buffer, b' ', 4), Some("root"));
139+
let mut ser = Serializer::with_root(Writer::new(&mut buffer), Some("root"));
141140

142141
let data = (42.0, "answer");
143142
data.serialize(&mut ser).unwrap();
@@ -153,8 +152,7 @@ fn tuple_struct() {
153152
struct Tuple(f32, &'static str);
154153

155154
let mut buffer = Vec::new();
156-
let mut ser =
157-
Serializer::with_root(Writer::new_with_indent(&mut buffer, b' ', 4), Some("root"));
155+
let mut ser = Serializer::with_root(Writer::new(&mut buffer), Some("root"));
158156

159157
let data = Tuple(42.0, "answer");
160158
data.serialize(&mut ser).unwrap();
@@ -173,8 +171,7 @@ fn struct_() {
173171
}
174172

175173
let mut buffer = Vec::new();
176-
let mut ser =
177-
Serializer::with_root(Writer::new_with_indent(&mut buffer, b' ', 4), Some("root"));
174+
let mut ser = Serializer::with_root(Writer::new(&mut buffer), Some("root"));
178175

179176
let node = Struct {
180177
float: 42.0,
@@ -201,8 +198,7 @@ fn nested_struct() {
201198
}
202199

203200
let mut buffer = Vec::new();
204-
let mut ser =
205-
Serializer::with_root(Writer::new_with_indent(&mut buffer, b' ', 4), Some("root"));
201+
let mut ser = Serializer::with_root(Writer::new(&mut buffer), Some("root"));
206202

207203
let node = Struct {
208204
nested: Nested { float: 42.0 },
@@ -211,8 +207,7 @@ fn nested_struct() {
211207
node.serialize(&mut ser).unwrap();
212208
assert_eq!(
213209
String::from_utf8(buffer).unwrap(),
214-
r#"<root string="answer"><nested float="42"/>
215-
</root>"#
210+
r#"<root string="answer"><nested float="42"/></root>"#
216211
);
217212
}
218213

@@ -231,8 +226,7 @@ fn flatten_struct() {
231226
}
232227

233228
let mut buffer = Vec::new();
234-
let mut ser =
235-
Serializer::with_root(Writer::new_with_indent(&mut buffer, b' ', 4), Some("root"));
229+
let mut ser = Serializer::with_root(Writer::new(&mut buffer), Some("root"));
236230

237231
let node = Struct {
238232
nested: Nested { float: 42.0 },
@@ -315,8 +309,7 @@ mod enum_ {
315309
#[test]
316310
fn struct_() {
317311
let mut buffer = Vec::new();
318-
let mut ser =
319-
Serializer::with_root(Writer::new_with_indent(&mut buffer, b' ', 4), Some("root"));
312+
let mut ser = Serializer::with_root(Writer::new(&mut buffer), Some("root"));
320313

321314
let node = Node::Struct {
322315
float: 42.0,
@@ -332,8 +325,7 @@ mod enum_ {
332325
#[test]
333326
fn tuple_struct() {
334327
let mut buffer = Vec::new();
335-
let mut ser =
336-
Serializer::with_root(Writer::new_with_indent(&mut buffer, b' ', 4), Some("root"));
328+
let mut ser = Serializer::with_root(Writer::new(&mut buffer), Some("root"));
337329

338330
let node = Node::Tuple(42.0, "answer".to_string());
339331
node.serialize(&mut ser).unwrap();
@@ -346,8 +338,7 @@ mod enum_ {
346338
#[test]
347339
fn nested_struct() {
348340
let mut buffer = Vec::new();
349-
let mut ser =
350-
Serializer::with_root(Writer::new_with_indent(&mut buffer, b' ', 4), Some("root"));
341+
let mut ser = Serializer::with_root(Writer::new(&mut buffer), Some("root"));
351342

352343
let node = Node::Holder {
353344
nested: Nested { float: 42.0 },
@@ -356,16 +347,14 @@ mod enum_ {
356347
node.serialize(&mut ser).unwrap();
357348
assert_eq!(
358349
String::from_utf8(buffer).unwrap(),
359-
r#"<Holder string="answer"><nested float="42"/>
360-
</Holder>"#
350+
r#"<Holder string="answer"><nested float="42"/></Holder>"#
361351
);
362352
}
363353

364354
#[test]
365355
fn flatten_struct() {
366356
let mut buffer = Vec::new();
367-
let mut ser =
368-
Serializer::with_root(Writer::new_with_indent(&mut buffer, b' ', 4), Some("root"));
357+
let mut ser = Serializer::with_root(Writer::new(&mut buffer), Some("root"));
369358

370359
let node = Node::Flatten {
371360
nested: Nested { float: 42.0 },
@@ -436,8 +425,7 @@ mod enum_ {
436425
#[test]
437426
fn struct_() {
438427
let mut buffer = Vec::new();
439-
let mut ser =
440-
Serializer::with_root(Writer::new_with_indent(&mut buffer, b' ', 4), Some("root"));
428+
let mut ser = Serializer::with_root(Writer::new(&mut buffer), Some("root"));
441429

442430
let node = Node::Struct {
443431
float: 42.0,
@@ -453,8 +441,7 @@ mod enum_ {
453441
#[test]
454442
fn nested_struct() {
455443
let mut buffer = Vec::new();
456-
let mut ser =
457-
Serializer::with_root(Writer::new_with_indent(&mut buffer, b' ', 4), Some("root"));
444+
let mut ser = Serializer::with_root(Writer::new(&mut buffer), Some("root"));
458445

459446
let node = Node::Holder {
460447
nested: Nested { float: 42.0 },
@@ -463,16 +450,14 @@ mod enum_ {
463450
node.serialize(&mut ser).unwrap();
464451
assert_eq!(
465452
String::from_utf8(buffer).unwrap(),
466-
r#"<root tag="Holder" string="answer"><nested float="42"/>
467-
</root>"#
453+
r#"<root tag="Holder" string="answer"><nested float="42"/></root>"#
468454
);
469455
}
470456

471457
#[test]
472458
fn flatten_struct() {
473459
let mut buffer = Vec::new();
474-
let mut ser =
475-
Serializer::with_root(Writer::new_with_indent(&mut buffer, b' ', 4), Some("root"));
460+
let mut ser = Serializer::with_root(Writer::new(&mut buffer), Some("root"));
476461

477462
let node = Node::Flatten {
478463
nested: Nested { float: 42.0 },
@@ -537,23 +522,20 @@ mod enum_ {
537522
#[test]
538523
fn tuple_struct() {
539524
let mut buffer = Vec::new();
540-
let mut ser =
541-
Serializer::with_root(Writer::new_with_indent(&mut buffer, b' ', 4), Some("root"));
525+
let mut ser = Serializer::with_root(Writer::new(&mut buffer), Some("root"));
542526

543527
let node = Node::Tuple(42.0, "answer".to_string());
544528
node.serialize(&mut ser).unwrap();
545529
assert_eq!(
546530
String::from_utf8(buffer).unwrap(),
547-
r#"<root tag="Tuple"><content>42</content><content>answer</content>
548-
</root>"#
531+
r#"<root tag="Tuple"><content>42</content><content>answer</content></root>"#
549532
);
550533
}
551534

552535
#[test]
553536
fn struct_() {
554537
let mut buffer = Vec::new();
555-
let mut ser =
556-
Serializer::with_root(Writer::new_with_indent(&mut buffer, b' ', 4), Some("root"));
538+
let mut ser = Serializer::with_root(Writer::new(&mut buffer), Some("root"));
557539

558540
let node = Node::Struct {
559541
float: 42.0,
@@ -562,16 +544,14 @@ mod enum_ {
562544
node.serialize(&mut ser).unwrap();
563545
assert_eq!(
564546
String::from_utf8(buffer).unwrap(),
565-
r#"<root tag="Struct"><content float="42" string="answer"/>
566-
</root>"#
547+
r#"<root tag="Struct"><content float="42" string="answer"/></root>"#
567548
);
568549
}
569550

570551
#[test]
571552
fn nested_struct() {
572553
let mut buffer = Vec::new();
573-
let mut ser =
574-
Serializer::with_root(Writer::new_with_indent(&mut buffer, b' ', 4), Some("root"));
554+
let mut ser = Serializer::with_root(Writer::new(&mut buffer), Some("root"));
575555

576556
let node = Node::Holder {
577557
nested: Nested { float: 42.0 },
@@ -580,16 +560,14 @@ mod enum_ {
580560
node.serialize(&mut ser).unwrap();
581561
assert_eq!(
582562
String::from_utf8(buffer).unwrap(),
583-
r#"<root tag="Holder"><content string="answer"><nested float="42"/></content>
584-
</root>"#
563+
r#"<root tag="Holder"><content string="answer"><nested float="42"/></content></root>"#
585564
);
586565
}
587566

588567
#[test]
589568
fn flatten_struct() {
590569
let mut buffer = Vec::new();
591-
let mut ser =
592-
Serializer::with_root(Writer::new_with_indent(&mut buffer, b' ', 4), Some("root"));
570+
let mut ser = Serializer::with_root(Writer::new(&mut buffer), Some("root"));
593571

594572
let node = Node::Flatten {
595573
nested: Nested { float: 42.0 },
@@ -598,8 +576,7 @@ mod enum_ {
598576
node.serialize(&mut ser).unwrap();
599577
assert_eq!(
600578
String::from_utf8(buffer).unwrap(),
601-
r#"<root tag="Flatten"><content><float>42</float><string>answer</string></content>
602-
</root>"#
579+
r#"<root tag="Flatten"><content><float>42</float><string>answer</string></content></root>"#
603580
);
604581
}
605582
}
@@ -654,8 +631,7 @@ mod enum_ {
654631
#[test]
655632
fn tuple_struct() {
656633
let mut buffer = Vec::new();
657-
let mut ser =
658-
Serializer::with_root(Writer::new_with_indent(&mut buffer, b' ', 4), Some("root"));
634+
let mut ser = Serializer::with_root(Writer::new(&mut buffer), Some("root"));
659635

660636
let node = Node::Tuple(42.0, "answer".to_string());
661637
node.serialize(&mut ser).unwrap();
@@ -668,8 +644,7 @@ mod enum_ {
668644
#[test]
669645
fn struct_() {
670646
let mut buffer = Vec::new();
671-
let mut ser =
672-
Serializer::with_root(Writer::new_with_indent(&mut buffer, b' ', 4), Some("root"));
647+
let mut ser = Serializer::with_root(Writer::new(&mut buffer), Some("root"));
673648

674649
let node = Node::Struct {
675650
float: 42.0,
@@ -685,8 +660,7 @@ mod enum_ {
685660
#[test]
686661
fn nested_struct() {
687662
let mut buffer = Vec::new();
688-
let mut ser =
689-
Serializer::with_root(Writer::new_with_indent(&mut buffer, b' ', 4), Some("root"));
663+
let mut ser = Serializer::with_root(Writer::new(&mut buffer), Some("root"));
690664

691665
let node = Node::Holder {
692666
nested: Nested { float: 42.0 },
@@ -695,16 +669,14 @@ mod enum_ {
695669
node.serialize(&mut ser).unwrap();
696670
assert_eq!(
697671
String::from_utf8(buffer).unwrap(),
698-
r#"<root string="answer"><nested float="42"/>
699-
</root>"#
672+
r#"<root string="answer"><nested float="42"/></root>"#
700673
);
701674
}
702675

703676
#[test]
704677
fn flatten_struct() {
705678
let mut buffer = Vec::new();
706-
let mut ser =
707-
Serializer::with_root(Writer::new_with_indent(&mut buffer, b' ', 4), Some("root"));
679+
let mut ser = Serializer::with_root(Writer::new(&mut buffer), Some("root"));
708680

709681
let node = Node::Flatten {
710682
nested: Nested { float: 42.0 },

0 commit comments

Comments
 (0)