Skip to content

Commit ee7679d

Browse files
removed AmqpType from tests to simplify them
1 parent 3a4d404 commit ee7679d

File tree

4 files changed

+17
-19
lines changed

4 files changed

+17
-19
lines changed

amqp-type/src/amqp_type.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,12 @@ impl Encode for AmqpType {
7575
}
7676
}
7777

78+
impl From<bool> for AmqpType {
79+
fn from(value: bool) -> Self {
80+
AmqpType::Boolean(value)
81+
}
82+
}
83+
7884
impl From<Timestamp> for AmqpType {
7985
fn from(value: Timestamp) -> Self {
8086
AmqpType::Timestamp(value)

amqp-type/src/compound/list.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@ mod test {
3232
use super::*;
3333
#[test]
3434
fn construct_empty_list() {
35-
let val = AmqpType::List(vec![].into());
35+
let val = List(vec![]);
3636
assert_eq!(val.encode().constructor(), 0x45);
3737
}
3838

3939
#[test]
4040
fn construct_list_with_less_than_255_elements() {
41-
let val = AmqpType::List(vec![1.into()].into());
41+
let val = List(vec![1.into()]);
4242
assert_eq!(val.encode().constructor(), 0xc0);
4343
}
4444

@@ -48,7 +48,7 @@ mod test {
4848
for i in 0..500 {
4949
arr.push(i.into())
5050
}
51-
let val = AmqpType::List(arr.into());
51+
let val = List(arr);
5252
assert_eq!(val.encode().constructor(), 0xd0);
5353
}
5454

@@ -58,7 +58,7 @@ mod test {
5858
for _ in 0..100 {
5959
arr.push("aaaaaaaaaaaaaaaaaaaa".into());
6060
}
61-
let val = AmqpType::List(arr.into());
61+
let val = List(arr);
6262
assert_eq!(val.encode().constructor(), 0xd0);
6363
}
6464
}

amqp-type/src/compound/map.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ mod test {
4646
use super::*;
4747
#[test]
4848
fn construct_map_with_less_than_255_elements() {
49-
let val = AmqpType::Map(IndexMap::new().into());
49+
let val = Map(IndexMap::new());
5050
assert_eq!(val.encode().constructor(), 0xc1);
5151
}
5252

@@ -56,7 +56,7 @@ mod test {
5656
for i in 1..500 {
5757
map.insert(i.into(), i.into());
5858
}
59-
let val = AmqpType::Map(map.into());
59+
let val = Map(map);
6060
assert_eq!(val.encode().constructor(), 0xd1);
6161
}
6262
}

amqp-type/src/fixed_width/boolean.rs

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
1-
use crate::amqp_type::AmqpType;
21
use crate::serde::encode::{Encode, Encoded};
32

4-
impl From<bool> for AmqpType {
5-
fn from(value: bool) -> Self {
6-
AmqpType::Boolean(value)
7-
}
8-
}
9-
103
impl Encode for bool {
114
#[cfg(feature = "zero-length-bools")]
125
fn encode(&self) -> Encoded {
@@ -28,25 +21,24 @@ impl Encode for bool {
2821
#[cfg(test)]
2922
mod test {
3023
use crate::serde::encode::Encode;
24+
3125
use super::*;
26+
3227
#[test]
3328
#[cfg(not(feature = "zero-length-bools"))]
3429
fn construct_bool() {
35-
let val = AmqpType::Boolean(true);
36-
assert_eq!(val.encode().constructor(), 0x56);
30+
assert_eq!(true.encode().constructor(), 0x56);
3731
}
3832

3933
#[test]
4034
#[cfg(feature = "zero-length-bools")]
4135
fn amqp_type_constructs_bool_false_as_zero_length() {
42-
let val = AmqpType::Boolean(false);
43-
assert_eq!(val.encode().constructor(), 0x42);
36+
assert_eq!(false.encode().constructor(), 0x42);
4437
}
4538

4639
#[test]
4740
#[cfg(feature = "zero-length-bools")]
4841
fn amqp_type_constructs_bool_true_as_zero_length() {
49-
let val = AmqpType::Boolean(true);
50-
assert_eq!(val.encode().constructor(), 0x41)
42+
assert_eq!(true.encode().constructor(), 0x41)
5143
}
5244
}

0 commit comments

Comments
 (0)