Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vE5li committed Feb 21, 2024
1 parent c5aec56 commit e77cd03
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 49 deletions.
45 changes: 0 additions & 45 deletions src/loaders/convertable/helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,51 +18,6 @@ pub fn conversion_result<S: Named, T>(result: Result<T, Box<ConversionError>>) -
})
}

#[cfg(test)]
mod length_hint_none {
use procedural::Named;

use super::check_length_hint_none;

#[derive(Named)]
struct Dummy {}

#[test]
fn none() {
let result = check_length_hint_none::<Dummy>(None);
assert!(result.is_ok());
}

#[test]
fn some() {
let result = check_length_hint_none::<Dummy>(Some(0));
assert!(result.is_err());
}
}

#[cfg(test)]
mod length_hint {
use procedural::Named;

use super::check_length_hint;

#[derive(Named)]
struct Dummy {}

#[test]
fn none() {
let result = check_length_hint::<Dummy>(None);
assert!(result.is_err());
}

#[test]
fn some() {
const LENGTH_HINT: usize = 0;
let result = check_length_hint::<Dummy>(Some(LENGTH_HINT));
assert!(result.is_ok_and(|value| value == LENGTH_HINT));
}
}

#[cfg(test)]
mod upper_bound {
use procedural::Named;
Expand Down
8 changes: 4 additions & 4 deletions src/loaders/convertable/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ mod default_string {

#[cfg(test)]
mod length_hint_string {
use crate::loaders::{ByteStream, FromBytes, ToBytes};
use crate::loaders::{ByteStream, FromBytesExt, ToBytesExt};

#[test]
fn serialization_test() {
Expand Down Expand Up @@ -501,7 +501,7 @@ mod const_length_hint_string {
#[test]
fn serialization_test() {
let test_value = TestStruct::new("test".to_string());
let data = test_value.to_bytes(None).unwrap();
let data = test_value.to_bytes().unwrap();
assert_eq!(data, vec![116, 101, 115, 116, 0, 0, 0, 0]);
}

Expand Down Expand Up @@ -531,7 +531,7 @@ mod dynamic_length_hint_string {
#[test]
fn serialization_test() {
let test_value = TestStruct::new(4, "test".to_string());
let data = test_value.to_bytes(None).unwrap();
let data = test_value.to_bytes().unwrap();
assert_eq!(data, vec![4, 116, 101, 115, 116, 0, 0, 0, 0]);
}

Expand Down Expand Up @@ -561,7 +561,7 @@ mod default_struct {
#[test]
fn serialization_test() {
let test_value = TestStruct::new(16, 3000, -1);
let data = test_value.to_bytes(None).unwrap();
let data = test_value.to_bytes().unwrap();
assert_eq!(data, vec![16, 184, 11, 255, 255, 255, 255]);
}

Expand Down

0 comments on commit e77cd03

Please sign in to comment.