tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test.rs (938B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      4 
      5 pub fn assert_ser_de<T>(data: &T, json: serde_json::Value)
      6 where
      7    T: std::fmt::Debug,
      8    T: std::cmp::PartialEq,
      9    T: serde::de::DeserializeOwned,
     10    T: serde::Serialize,
     11 {
     12    assert_eq!(serde_json::to_value(data).unwrap(), json);
     13    assert_eq!(data, &serde_json::from_value::<T>(json).unwrap());
     14 }
     15 
     16 pub fn assert_ser<T>(data: &T, json: serde_json::Value)
     17 where
     18    T: std::fmt::Debug,
     19    T: std::cmp::PartialEq,
     20    T: serde::Serialize,
     21 {
     22    assert_eq!(serde_json::to_value(data).unwrap(), json);
     23 }
     24 
     25 pub fn assert_de<T>(data: &T, json: serde_json::Value)
     26 where
     27    T: std::fmt::Debug,
     28    T: std::cmp::PartialEq,
     29    T: serde::de::DeserializeOwned,
     30 {
     31    assert_eq!(data, &serde_json::from_value::<T>(json).unwrap());
     32 }