Add a single driver for tests and benchmarks
This commit is contained in:
parent
24ac61f9f2
commit
482f92af61
@ -16,3 +16,11 @@ num = "*"
|
||||
rustc-serialize = "*"
|
||||
serde = { version = "*", path = "../serde" }
|
||||
serde_macros = { version = "*", path = "../serde_macros" }
|
||||
|
||||
[[test]]
|
||||
name = "test"
|
||||
path = "tests/test.rs"
|
||||
|
||||
[[bench]]
|
||||
name = "bench"
|
||||
path = "benches/bench.rs"
|
||||
|
9
serde_tests/benches/bench.rs
Normal file
9
serde_tests/benches/bench.rs
Normal file
@ -0,0 +1,9 @@
|
||||
#![feature(custom_attribute, custom_derive, plugin, test)]
|
||||
#![plugin(serde_macros)]
|
||||
|
||||
extern crate serde;
|
||||
extern crate test;
|
||||
|
||||
mod syntax {
|
||||
include!("bench.rs.in");
|
||||
}
|
5
serde_tests/benches/bench.rs.in
Normal file
5
serde_tests/benches/bench.rs.in
Normal file
@ -0,0 +1,5 @@
|
||||
mod bench_enum;
|
||||
mod bench_log;
|
||||
mod bench_map;
|
||||
mod bench_struct;
|
||||
mod bench_vec;
|
@ -1,18 +1,8 @@
|
||||
#![feature(custom_derive, plugin, test)]
|
||||
#![plugin(serde_macros)]
|
||||
|
||||
extern crate serde;
|
||||
extern crate rustc_serialize;
|
||||
extern crate test;
|
||||
|
||||
use test::Bencher;
|
||||
|
||||
use rustc_serialize::{Decoder, Decodable};
|
||||
|
||||
use serde;
|
||||
use serde::de::{Deserializer, Deserialize};
|
||||
|
||||
use Animal::{Dog, Frog};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#[derive(Clone, PartialEq, Debug, RustcDecodable, Deserialize)]
|
||||
@ -408,7 +398,7 @@ mod deserializer {
|
||||
#[bench]
|
||||
fn bench_decoder_dog(b: &mut Bencher) {
|
||||
b.iter(|| {
|
||||
let animal = Dog;
|
||||
let animal = Animal::Dog;
|
||||
|
||||
let mut d = decoder::AnimalDecoder::new(animal.clone());
|
||||
let value: Animal = Decodable::decode(&mut d).unwrap();
|
||||
@ -420,7 +410,7 @@ fn bench_decoder_dog(b: &mut Bencher) {
|
||||
#[bench]
|
||||
fn bench_decoder_frog(b: &mut Bencher) {
|
||||
b.iter(|| {
|
||||
let animal = Frog("Henry".to_string(), 349);
|
||||
let animal = Animal::Frog("Henry".to_string(), 349);
|
||||
|
||||
let mut d = decoder::AnimalDecoder::new(animal.clone());
|
||||
let value: Animal = Decodable::decode(&mut d).unwrap();
|
||||
@ -432,7 +422,7 @@ fn bench_decoder_frog(b: &mut Bencher) {
|
||||
#[bench]
|
||||
fn bench_deserializer_dog(b: &mut Bencher) {
|
||||
b.iter(|| {
|
||||
let animal = Dog;
|
||||
let animal = Animal::Dog;
|
||||
|
||||
let mut d = deserializer::AnimalDeserializer::new(animal.clone());
|
||||
let value: Animal = Deserialize::deserialize(&mut d).unwrap();
|
||||
@ -444,7 +434,7 @@ fn bench_deserializer_dog(b: &mut Bencher) {
|
||||
#[bench]
|
||||
fn bench_deserializer_frog(b: &mut Bencher) {
|
||||
b.iter(|| {
|
||||
let animal = Frog("Henry".to_string(), 349);
|
||||
let animal = Animal::Frog("Henry".to_string(), 349);
|
||||
|
||||
let mut d = deserializer::AnimalDeserializer::new(animal.clone());
|
||||
let value: Animal = Deserialize::deserialize(&mut d).unwrap();
|
||||
|
@ -1,16 +1,9 @@
|
||||
#![feature(custom_derive, collections, plugin, test)]
|
||||
#![allow(non_camel_case_types)]
|
||||
#![plugin(serde_macros)]
|
||||
|
||||
extern crate num;
|
||||
extern crate rustc_serialize;
|
||||
extern crate serde;
|
||||
extern crate test;
|
||||
|
||||
use std::io::{self, Read, Write};
|
||||
use num::FromPrimitive;
|
||||
use test::Bencher;
|
||||
|
||||
use rustc_serialize;
|
||||
|
||||
use serde::de::{self, Deserialize, Deserializer};
|
||||
use serde::json::ser::escape_str;
|
||||
use serde::json;
|
||||
@ -32,6 +25,7 @@ struct Http {
|
||||
request_uri: String,
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
#[derive(Copy, Clone, Debug, PartialEq)]
|
||||
enum HttpProtocol {
|
||||
HTTP_PROTOCOL_UNKNOWN,
|
||||
@ -92,6 +86,7 @@ impl de::Deserialize for HttpProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
#[derive(Copy, Clone, Debug, PartialEq)]
|
||||
enum HttpMethod {
|
||||
METHOD_UNKNOWN,
|
||||
@ -168,6 +163,7 @@ impl de::Deserialize for HttpMethod {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
#[derive(Copy, Clone, Debug, PartialEq)]
|
||||
enum CacheStatus {
|
||||
CACHESTATUS_UNKNOWN,
|
||||
@ -238,6 +234,7 @@ struct Origin {
|
||||
protocol: OriginProtocol,
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
#[derive(Copy, Clone, Debug, PartialEq)]
|
||||
enum OriginProtocol {
|
||||
ORIGIN_PROTOCOL_UNKNOWN,
|
||||
@ -298,6 +295,7 @@ impl de::Deserialize for OriginProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
#[derive(Copy, Clone, Debug, PartialEq)]
|
||||
enum ZonePlan {
|
||||
ZONEPLAN_UNKNOWN,
|
||||
@ -1018,12 +1016,20 @@ impl MyMemWriter0 {
|
||||
|
||||
|
||||
impl Write for MyMemWriter0 {
|
||||
#[cfg(feature = "nightly")]
|
||||
#[inline]
|
||||
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
|
||||
self.buf.push_all(buf);
|
||||
Ok(buf.len())
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "nightly"))]
|
||||
#[inline]
|
||||
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
|
||||
self.buf.extend(buf.iter().cloned());
|
||||
Ok(buf.len())
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn flush(&mut self) -> io::Result<()> {
|
||||
Ok(())
|
||||
|
@ -1,16 +1,10 @@
|
||||
#![feature(custom_derive, plugin, test)]
|
||||
#![plugin(serde_macros)]
|
||||
|
||||
extern crate serde;
|
||||
extern crate rustc_serialize;
|
||||
extern crate test;
|
||||
|
||||
use std::fmt::Debug;
|
||||
use std::collections::HashMap;
|
||||
use test::Bencher;
|
||||
|
||||
use rustc_serialize::{Decoder, Decodable};
|
||||
|
||||
use serde;
|
||||
use serde::de::{Deserializer, Deserialize};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -1,15 +1,9 @@
|
||||
#![feature(custom_derive, plugin, test)]
|
||||
#![plugin(serde_macros)]
|
||||
|
||||
extern crate serde;
|
||||
extern crate rustc_serialize;
|
||||
extern crate test;
|
||||
|
||||
use std::collections::HashMap;
|
||||
use test::Bencher;
|
||||
|
||||
use rustc_serialize::{Decoder, Decodable};
|
||||
|
||||
use serde;
|
||||
use serde::de::{Deserializer, Deserialize};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
@ -34,8 +28,6 @@ pub struct Outer {
|
||||
pub enum Error {
|
||||
EndOfStream,
|
||||
SyntaxError,
|
||||
UnexpectedName,
|
||||
ConversionError,
|
||||
MissingField,
|
||||
OtherError,
|
||||
}
|
||||
|
@ -1,15 +1,9 @@
|
||||
#![feature(plugin, test)]
|
||||
#![plugin(serde_macros)]
|
||||
|
||||
extern crate serde;
|
||||
extern crate rustc_serialize;
|
||||
extern crate test;
|
||||
|
||||
use std::fmt::Debug;
|
||||
use test::Bencher;
|
||||
|
||||
use rustc_serialize::{Decoder, Decodable};
|
||||
|
||||
use serde;
|
||||
use serde::de::{Deserializer, Deserialize};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
7
serde_tests/tests/test.rs
Normal file
7
serde_tests/tests/test.rs
Normal file
@ -0,0 +1,7 @@
|
||||
#![feature(custom_attribute, custom_derive, plugin, test)]
|
||||
#![plugin(serde_macros)]
|
||||
|
||||
extern crate serde;
|
||||
extern crate test;
|
||||
|
||||
include!("test.rs.in");
|
7
serde_tests/tests/test.rs.in
Normal file
7
serde_tests/tests/test.rs.in
Normal file
@ -0,0 +1,7 @@
|
||||
mod test_annotations;
|
||||
mod test_bytes;
|
||||
mod test_de;
|
||||
mod test_json;
|
||||
mod test_json_builder;
|
||||
mod test_macros;
|
||||
mod test_ser;
|
@ -1,9 +1,3 @@
|
||||
#![feature(custom_attribute, custom_derive, plugin, test)]
|
||||
#![plugin(serde_macros)]
|
||||
|
||||
extern crate test;
|
||||
extern crate serde;
|
||||
|
||||
use serde::json;
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
|
@ -1,9 +1,4 @@
|
||||
#![feature(custom_derive, plugin, test)]
|
||||
#![plugin(serde_macros)]
|
||||
|
||||
extern crate test;
|
||||
extern crate serde;
|
||||
|
||||
use serde;
|
||||
use serde::Serialize;
|
||||
use serde::bytes::{ByteBuf, Bytes};
|
||||
use serde::json;
|
||||
|
@ -1,9 +1,3 @@
|
||||
#![feature(custom_derive, plugin, test)]
|
||||
#![plugin(serde_macros)]
|
||||
|
||||
extern crate test;
|
||||
extern crate serde;
|
||||
|
||||
use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet};
|
||||
use std::iter;
|
||||
use std::vec;
|
||||
|
@ -1,9 +1,3 @@
|
||||
#![feature(custom_derive, plugin, test, custom_attribute)]
|
||||
#![plugin(serde_macros)]
|
||||
|
||||
extern crate test;
|
||||
extern crate serde;
|
||||
|
||||
use std::fmt::Debug;
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
|
@ -1,5 +1,3 @@
|
||||
extern crate serde;
|
||||
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
use serde::json::value::Value;
|
||||
|
@ -1,8 +1,3 @@
|
||||
#![feature(custom_derive, plugin)]
|
||||
#![plugin(serde_macros)]
|
||||
|
||||
extern crate serde;
|
||||
|
||||
use std::collections::BTreeMap;
|
||||
use serde::json::{self, Value};
|
||||
|
||||
|
@ -1,9 +1,3 @@
|
||||
#![feature(custom_derive, plugin, test)]
|
||||
#![plugin(serde_macros)]
|
||||
|
||||
extern crate test;
|
||||
extern crate serde;
|
||||
|
||||
use std::vec;
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user