Skip to content

Commit

Permalink
Ignore coverage on simple statements that dont make sense to be cover…
Browse files Browse the repository at this point in the history
…ed explicitly.

Signed-off-by: Matthias Wahl <mwahl@wayfair.com>
  • Loading branch information
Matthias Wahl committed Jan 28, 2021
1 parent fdf1e3b commit c5679b9
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tremor-value/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,14 @@ impl Display for Error {

impl std::error::Error for Error {}

#[cfg(not(tarpaulin_include))] // this is a simple error
impl serde_ext::de::Error for Error {
fn custom<T: fmt::Display>(msg: T) -> Self {
Error::Serde(msg.to_string())
}
}

#[cfg(not(tarpaulin_include))] // this is a simple error
impl serde_ext::ser::Error for Error {
fn custom<T: fmt::Display>(msg: T) -> Self {
Error::Serde(msg.to_string())
Expand Down
39 changes: 39 additions & 0 deletions tremor-value/src/serde/value/se.rs
Original file line number Diff line number Diff line change
Expand Up @@ -444,60 +444,72 @@ impl serde_ext::Serializer for MapKeySerializer {
value.serialize(self)
}

#[cfg(not(tarpaulin_include))] // this is a simple error
fn serialize_bool(self, _value: bool) -> Result<Self::Ok> {
Err(key_must_be_a_string())
}

#[cfg(not(tarpaulin_include))] // this is a simple error
fn serialize_i8(self, _value: i8) -> Result<Self::Ok> {
//Ok(value.to_string())
Err(key_must_be_a_string())
}

#[cfg(not(tarpaulin_include))] // this is a simple error
fn serialize_i16(self, _value: i16) -> Result<Self::Ok> {
//Ok(value.to_string())
Err(key_must_be_a_string())
}

#[cfg(not(tarpaulin_include))] // this is a simple error
fn serialize_i32(self, _value: i32) -> Result<Self::Ok> {
//Ok(value.to_string())
Err(key_must_be_a_string())
}

#[cfg(not(tarpaulin_include))] // this is a simple error
fn serialize_i64(self, _value: i64) -> Result<Self::Ok> {
//Ok(value.to_string())
Err(key_must_be_a_string())
}

#[cfg(not(tarpaulin_include))] // this is a simple error
fn serialize_u8(self, _value: u8) -> Result<Self::Ok> {
//Ok(value.to_string())
Err(key_must_be_a_string())
}

#[cfg(not(tarpaulin_include))] // this is a simple error
fn serialize_u16(self, _value: u16) -> Result<Self::Ok> {
//Ok(value.to_string())
Err(key_must_be_a_string())
}

#[cfg(not(tarpaulin_include))] // this is a simple error
fn serialize_u32(self, _value: u32) -> Result<Self::Ok> {
//Ok(value.to_string())
Err(key_must_be_a_string())
}

#[cfg(not(tarpaulin_include))] // this is a simple error
fn serialize_u64(self, _value: u64) -> Result<Self::Ok> {
//Ok(value.to_string())
Err(key_must_be_a_string())
}

#[cfg(not(tarpaulin_include))] // this is a simple error
fn serialize_f32(self, _value: f32) -> Result<Self::Ok> {
//Err(key_must_be_a_string())
Err(key_must_be_a_string())
}

#[cfg(not(tarpaulin_include))] // this is a simple error
fn serialize_f64(self, _value: f64) -> Result<Self::Ok> {
//Err(key_must_be_a_string())
Err(key_must_be_a_string())
}

#[cfg(not(tarpaulin_include))] // this is a simple error
fn serialize_char(self, _value: char) -> Result<Self::Ok> {
// Ok({
// let mut s = String::new();
Expand All @@ -512,18 +524,22 @@ impl serde_ext::Serializer for MapKeySerializer {
Ok(value.to_owned())
}

#[cfg(not(tarpaulin_include))] // this is a simple error
fn serialize_bytes(self, _value: &[u8]) -> Result<Self::Ok> {
Err(key_must_be_a_string())
}

#[cfg(not(tarpaulin_include))] // this is a simple error
fn serialize_unit(self) -> Result<Self::Ok> {
Err(key_must_be_a_string())
}

#[cfg(not(tarpaulin_include))] // this is a simple error
fn serialize_unit_struct(self, _name: &'static str) -> Result<Self::Ok> {
Err(key_must_be_a_string())
}

#[cfg(not(tarpaulin_include))] // this is a simple error
fn serialize_newtype_variant<T: ?Sized>(
self,
_name: &'static str,
Expand All @@ -537,25 +553,30 @@ impl serde_ext::Serializer for MapKeySerializer {
Err(key_must_be_a_string())
}

#[cfg(not(tarpaulin_include))] // this is a simple error
fn serialize_none(self) -> Result<Self::Ok> {
Err(key_must_be_a_string())
}

#[cfg(not(tarpaulin_include))] // this is a simple error
fn serialize_some<T: ?Sized>(self, _value: &T) -> Result<Self::Ok>
where
T: Serialize,
{
Err(key_must_be_a_string())
}

#[cfg(not(tarpaulin_include))] // this is a simple error
fn serialize_seq(self, _len: Option<usize>) -> Result<Self::SerializeSeq> {
Err(key_must_be_a_string())
}

#[cfg(not(tarpaulin_include))] // this is a simple error
fn serialize_tuple(self, _len: usize) -> Result<Self::SerializeTuple> {
Err(key_must_be_a_string())
}

#[cfg(not(tarpaulin_include))] // this is a simple error
fn serialize_tuple_struct(
self,
_name: &'static str,
Expand All @@ -564,6 +585,7 @@ impl serde_ext::Serializer for MapKeySerializer {
Err(key_must_be_a_string())
}

#[cfg(not(tarpaulin_include))] // this is a simple error
fn serialize_tuple_variant(
self,
_name: &'static str,
Expand All @@ -574,14 +596,17 @@ impl serde_ext::Serializer for MapKeySerializer {
Err(key_must_be_a_string())
}

#[cfg(not(tarpaulin_include))] // this is a simple error
fn serialize_map(self, _len: Option<usize>) -> Result<Self::SerializeMap> {
Err(key_must_be_a_string())
}

#[cfg(not(tarpaulin_include))] // this is a simple error
fn serialize_struct(self, _name: &'static str, _len: usize) -> Result<Self::SerializeStruct> {
Err(key_must_be_a_string())
}

#[cfg(not(tarpaulin_include))] // this is a simple error
fn serialize_struct_variant(
self,
_name: &'static str,
Expand Down Expand Up @@ -638,9 +663,12 @@ impl serde::ser::SerializeStructVariant for SerializeStructVariant {
}

#[cfg(test)]
#[cfg(not(tarpaulin_include))] // this is test code, duh
mod tests {

use super::*;

use beef::Cow;
use serde_ext::Serialize;
#[derive(Serialize)]
enum Snot {
Expand Down Expand Up @@ -1011,4 +1039,15 @@ mod tests {
Ok(())
}
*/

#[test]
fn serialize_value_bytes() -> Result<()> {
let bytes = Value::Bytes(Cow::borrowed(&[1, 2, 3]));
let serialized = bytes.serialize(Serializer::default());
assert!(serialized.is_ok());

// stupidly asserting that it remains the same
assert_eq!(bytes, serialized.unwrap());
Ok(())
}
}

0 comments on commit c5679b9

Please sign in to comment.