better tests organization
This commit is contained in:
parent
ffe7da2995
commit
53e3c568a8
17
src/de.rs
17
src/de.rs
@ -1,15 +1,11 @@
|
|||||||
use std::collections::{HashMap, HashSet};
|
|
||||||
use serde::de::{
|
use serde::de::{
|
||||||
self, DeserializeSeed, MapAccess, SeqAccess,
|
self, DeserializeSeed, MapAccess, SeqAccess,
|
||||||
Visitor,
|
Visitor,
|
||||||
};
|
};
|
||||||
use serde::{Serialize};
|
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
|
||||||
use crate::bipack_source::{BipackSource, VecSource};
|
use crate::bipack_source::{BipackSource, VecSource};
|
||||||
use crate::error::{Error, Result};
|
use crate::error::{Error, Result};
|
||||||
use crate::ser::to_bytes;
|
|
||||||
use crate::tools::to_dump;
|
|
||||||
|
|
||||||
pub struct Deserializer {
|
pub struct Deserializer {
|
||||||
// This string starts with the input data and characters are truncated off
|
// This string starts with the input data and characters are truncated off
|
||||||
@ -236,6 +232,16 @@ fn test_ints() -> Result<()> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mod tests {
|
||||||
|
use std::collections::{HashMap, HashSet};
|
||||||
|
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
use crate::de::from_bytes;
|
||||||
|
use crate::error::Result;
|
||||||
|
use crate::ser::to_bytes;
|
||||||
|
use crate::tools::to_dump;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_struct() -> Result<()> {
|
fn test_struct() -> Result<()> {
|
||||||
#[derive(Serialize, Deserialize, PartialEq, Debug)]
|
#[derive(Serialize, Deserialize, PartialEq, Debug)]
|
||||||
@ -261,7 +267,6 @@ fn test_struct() -> Result<()> {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_map() -> Result<()> {
|
fn test_map() -> Result<()> {
|
||||||
|
|
||||||
let mut src = HashMap::new();
|
let mut src = HashMap::new();
|
||||||
src.insert("foo".to_string(), 1);
|
src.insert("foo".to_string(), 1);
|
||||||
src.insert("foo".to_string(), 42);
|
src.insert("foo".to_string(), 42);
|
||||||
@ -279,7 +284,6 @@ fn test_map() -> Result<()> {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_set() -> Result<()> {
|
fn test_set() -> Result<()> {
|
||||||
|
|
||||||
let src = HashSet::from(["foo", "bar", "buz"].map(|i| i.to_string()));
|
let src = HashSet::from(["foo", "bar", "buz"].map(|i| i.to_string()));
|
||||||
let packed = to_bytes(&src)?;
|
let packed = to_bytes(&src)?;
|
||||||
println!("{}", to_dump(&packed));
|
println!("{}", to_dump(&packed));
|
||||||
@ -290,3 +294,4 @@ fn test_set() -> Result<()> {
|
|||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user