Skip to content

Commit

Permalink
chore(tests): update unit tests and benchmarks to visit -> (de)serial…
Browse files Browse the repository at this point in the history
…ize renaming
  • Loading branch information
oli-obk committed Oct 19, 2015
1 parent 53dc120 commit e05737a
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 69 deletions.
4 changes: 2 additions & 2 deletions serde_tests/benches/bench_enum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ mod deserializer {
type Error = Error;

#[inline]
fn visit<V>(&mut self, mut visitor: V) -> Result<V::Value, Error>
fn deserialize<V>(&mut self, mut visitor: V) -> Result<V::Value, Error>
where V: de::Visitor,
{
match self.stack.pop() {
Expand All @@ -288,7 +288,7 @@ mod deserializer {
}

#[inline]
fn visit_enum<V>(&mut self,
fn deserialize_enum<V>(&mut self,
_name: &str,
_variants: &[&str],
mut visitor: V) -> Result<V::Value, Error>
Expand Down
10 changes: 5 additions & 5 deletions serde_tests/benches/bench_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ mod deserializer {
impl de::Deserializer for IsizeDeserializer {
type Error = Error;

fn visit<V>(&mut self, mut visitor: V) -> Result<V::Value, Error>
fn deserialize<V>(&mut self, mut visitor: V) -> Result<V::Value, Error>
where V: de::Visitor,
{
match self.stack.pop() {
Expand Down Expand Up @@ -399,7 +399,7 @@ fn bench_decoder_000(b: &mut Bencher) {
fn bench_decoder_003(b: &mut Bencher) {
b.iter(|| {
let mut m: HashMap<String, isize> = HashMap::new();
for i in (0 .. 3) {
for i in 0 .. 3 {
m.insert(i.to_string(), i);
}
run_decoder(decoder::IsizeDecoder::new(m.clone()), m)
Expand All @@ -410,7 +410,7 @@ fn bench_decoder_003(b: &mut Bencher) {
fn bench_decoder_100(b: &mut Bencher) {
b.iter(|| {
let mut m: HashMap<String, isize> = HashMap::new();
for i in (0 .. 100) {
for i in 0 .. 100 {
m.insert(i.to_string(), i);
}
run_decoder(decoder::IsizeDecoder::new(m.clone()), m)
Expand Down Expand Up @@ -439,7 +439,7 @@ fn bench_deserializer_000(b: &mut Bencher) {
fn bench_deserializer_003(b: &mut Bencher) {
b.iter(|| {
let mut m: HashMap<String, isize> = HashMap::new();
for i in (0 .. 3) {
for i in 0 .. 3 {
m.insert(i.to_string(), i);
}
run_deserializer(deserializer::IsizeDeserializer::new(m.clone()), m)
Expand All @@ -450,7 +450,7 @@ fn bench_deserializer_003(b: &mut Bencher) {
fn bench_deserializer_100(b: &mut Bencher) {
b.iter(|| {
let mut m: HashMap<String, isize> = HashMap::new();
for i in (0 .. 100) {
for i in 0 .. 100 {
m.insert(i.to_string(), i);
}
run_deserializer(deserializer::IsizeDeserializer::new(m.clone()), m)
Expand Down
4 changes: 2 additions & 2 deletions serde_tests/benches/bench_struct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ mod deserializer {
impl de::Deserializer for OuterDeserializer {
type Error = Error;

fn visit<V>(&mut self, mut visitor: V) -> Result<V::Value, Error>
fn deserialize<V>(&mut self, mut visitor: V) -> Result<V::Value, Error>
where V: de::Visitor,
{
match self.stack.pop() {
Expand Down Expand Up @@ -398,7 +398,7 @@ mod deserializer {
}
}

fn visit_struct<V>(&mut self,
fn deserialize_struct<V>(&mut self,
name: &str,
_fields: &'static [&'static str],
mut visitor: V) -> Result<V::Value, Error>
Expand Down
4 changes: 2 additions & 2 deletions serde_tests/benches/bench_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ mod deserializer {
type Error = Error;

#[inline]
fn visit<V>(&mut self, mut visitor: V) -> Result<V::Value, Error>
fn deserialize<V>(&mut self, mut visitor: V) -> Result<V::Value, Error>
where V: de::Visitor,
{
match self.state {
Expand Down Expand Up @@ -437,7 +437,7 @@ mod deserializer {
type Error = Error;

#[inline]
fn visit<V>(&mut self, mut visitor: V) -> Result<V::Value, Error>
fn deserialize<V>(&mut self, mut visitor: V) -> Result<V::Value, Error>
where V: de::Visitor,
{
match self.state {
Expand Down
34 changes: 17 additions & 17 deletions serde_tests/tests/test_bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,74 +34,74 @@ impl BytesSerializer {
impl serde::Serializer for BytesSerializer {
type Error = Error;

fn visit_unit(&mut self) -> Result<(), Error> {
fn serialize_unit(&mut self) -> Result<(), Error> {
Err(Error)
}

fn visit_bool(&mut self, _v: bool) -> Result<(), Error> {
fn serialize_bool(&mut self, _v: bool) -> Result<(), Error> {
Err(Error)
}

fn visit_i64(&mut self, _v: i64) -> Result<(), Error> {
fn serialize_i64(&mut self, _v: i64) -> Result<(), Error> {
Err(Error)
}

fn visit_u64(&mut self, _v: u64) -> Result<(), Error> {
fn serialize_u64(&mut self, _v: u64) -> Result<(), Error> {
Err(Error)
}

fn visit_f32(&mut self, _v: f32) -> Result<(), Error> {
fn serialize_f32(&mut self, _v: f32) -> Result<(), Error> {
Err(Error)
}

fn visit_f64(&mut self, _v: f64) -> Result<(), Error> {
fn serialize_f64(&mut self, _v: f64) -> Result<(), Error> {
Err(Error)
}

fn visit_char(&mut self, _v: char) -> Result<(), Error> {
fn serialize_char(&mut self, _v: char) -> Result<(), Error> {
Err(Error)
}

fn visit_str(&mut self, _v: &str) -> Result<(), Error> {
fn serialize_str(&mut self, _v: &str) -> Result<(), Error> {
Err(Error)
}

fn visit_none(&mut self) -> Result<(), Error> {
fn serialize_none(&mut self) -> Result<(), Error> {
Err(Error)
}

fn visit_some<V>(&mut self, _value: V) -> Result<(), Error>
fn serialize_some<V>(&mut self, _value: V) -> Result<(), Error>
where V: serde::Serialize,
{
Err(Error)
}

fn visit_seq<V>(&mut self, _visitor: V) -> Result<(), Error>
fn serialize_seq<V>(&mut self, _visitor: V) -> Result<(), Error>
where V: serde::ser::SeqVisitor,
{
Err(Error)
}

fn visit_seq_elt<T>(&mut self, _value: T) -> Result<(), Error>
fn serialize_seq_elt<T>(&mut self, _value: T) -> Result<(), Error>
where T: serde::Serialize
{
Err(Error)
}

fn visit_map<V>(&mut self, _visitor: V) -> Result<(), Error>
fn serialize_map<V>(&mut self, _visitor: V) -> Result<(), Error>
where V: serde::ser::MapVisitor,
{
Err(Error)
}

fn visit_map_elt<K, V>(&mut self, _key: K, _value: V) -> Result<(), Error>
fn serialize_map_elt<K, V>(&mut self, _key: K, _value: V) -> Result<(), Error>
where K: serde::Serialize,
V: serde::Serialize,
{
Err(Error)
}

fn visit_bytes(&mut self, bytes: &[u8]) -> Result<(), Error> {
fn serialize_bytes(&mut self, bytes: &[u8]) -> Result<(), Error> {
assert_eq!(self.bytes, bytes);
Ok(())
}
Expand All @@ -124,13 +124,13 @@ impl BytesDeserializer {
impl serde::Deserializer for BytesDeserializer {
type Error = Error;

fn visit<V>(&mut self, _visitor: V) -> Result<V::Value, Error>
fn deserialize<V>(&mut self, _visitor: V) -> Result<V::Value, Error>
where V: serde::de::Visitor,
{
Err(Error)
}

fn visit_bytes<V>(&mut self, mut visitor: V) -> Result<V::Value, Error>
fn deserialize_bytes<V>(&mut self, mut visitor: V) -> Result<V::Value, Error>
where V: serde::de::Visitor,
{
visitor.visit_byte_buf(self.bytes.take().unwrap())
Expand Down
Loading

0 comments on commit e05737a

Please sign in to comment.