Start fixing the json tests

This commit is contained in:
Erick Tryzelaar 2015-03-04 06:57:19 -08:00
parent 6685d76e2c
commit 4b2354597d
2 changed files with 17 additions and 7 deletions

View File

@ -104,12 +104,6 @@ impl ser::Visitor for Serializer {
type Value = (); type Value = ();
type Error = (); type Error = ();
#[inline]
fn visit_unit(&mut self) -> Result<(), ()> {
self.state.push(State::Value(Value::Null));
Ok(())
}
#[inline] #[inline]
fn visit_bool(&mut self, value: bool) -> Result<(), ()> { fn visit_bool(&mut self, value: bool) -> Result<(), ()> {
self.state.push(State::Value(Value::Bool(value))); self.state.push(State::Value(Value::Bool(value)));
@ -158,6 +152,22 @@ impl ser::Visitor for Serializer {
value.visit(self) value.visit(self)
} }
#[inline]
fn visit_unit(&mut self) -> Result<(), ()> {
self.state.push(State::Value(Value::Null));
Ok(())
}
#[inline]
fn visit_enum_unit(&mut self, _name: &str, variant: &str) -> Result<(), ()> {
let mut values = BTreeMap::new();
values.insert(variant.to_string(), Value::Array(vec![]));
self.state.push(State::Value(Value::Object(values)));
Ok(())
}
#[inline] #[inline]
fn visit_seq<V>(&mut self, mut visitor: V) -> Result<(), ()> fn visit_seq<V>(&mut self, mut visitor: V) -> Result<(), ()>
where V: ser::SeqVisitor, where V: ser::SeqVisitor,

View File

@ -346,7 +346,6 @@ fn test_write_tuple() {
*/ */
} }
/*
#[test] #[test]
fn test_write_enum() { fn test_write_enum() {
test_encode_ok(&[ test_encode_ok(&[
@ -408,6 +407,7 @@ fn test_write_enum() {
*/ */
} }
/*
#[test] #[test]
fn test_write_option() { fn test_write_option() {
test_encode_ok(&[ test_encode_ok(&[