Skip to content

Commit

Permalink
attempt to fix tests, looks like bindgen broke our string enums though
Browse files Browse the repository at this point in the history
  • Loading branch information
shanemadden committed Aug 14, 2024
1 parent 43ec6ec commit 0bc6a5a
Showing 1 changed file with 21 additions and 58 deletions.
79 changes: 21 additions & 58 deletions src/constants/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -834,32 +834,26 @@ mod test {
#[test]
fn resources_rust_to_serde_json_from_serde_json_roundtrip() {
for resource in enum_iterator::all::<ResourceType>() {
if resource != ResourceType::__Nonexhaustive {
let serialized = serde_json::to_string(&resource).unwrap();
let parsed: ResourceType = serde_json::from_str(&serialized).unwrap();
assert_eq!(resource, parsed);
}
let serialized = serde_json::to_string(&resource).unwrap();
let parsed: ResourceType = serde_json::from_str(&serialized).unwrap();
assert_eq!(resource, parsed);
}
}

#[test]
fn resources_rust_to_display_from_str_roundtrip() {
for resource in enum_iterator::all::<ResourceType>() {
if resource != ResourceType::__Nonexhaustive {
let string = format!("{}", resource);
let parsed = ResourceType::from_str(&string).unwrap();
assert_eq!(resource, parsed);
}
let string = format!("{}", resource);
let parsed = ResourceType::from_str(&string).unwrap();
assert_eq!(resource, parsed);
}
}

#[test]
fn resources_rust_vec_to_serde_json_from_serde_json_roundtrip() {
let mut resources = vec![];
for resource in enum_iterator::all::<ResourceType>() {
if resource != ResourceType::__Nonexhaustive {
resources.push(resource);
}
resources.push(resource);
}
let serialized = serde_json::to_string(&resources).unwrap();
let resources_reparsed: Vec<ResourceType> = serde_json::from_str(&serialized).unwrap();
Expand All @@ -870,9 +864,7 @@ mod test {
fn resources_rust_vec_to_serde_json_from_serde_json_roundtrip_via_values() {
let mut resources = vec![];
for resource in enum_iterator::all::<ResourceType>() {
if resource != ResourceType::__Nonexhaustive {
resources.push(resource);
}
resources.push(resource);
}
let serialized = serde_json::to_string(&resources).unwrap();
let resources_reparsed_values: Vec<serde_json::Value> =
Expand All @@ -887,32 +879,26 @@ mod test {
#[test]
fn intershard_resources_rust_to_serde_json_from_serde_json_roundtrip() {
for resource in enum_iterator::all::<IntershardResourceType>() {
if resource != IntershardResourceType::__Nonexhaustive {
let serialized = serde_json::to_string(&resource).unwrap();
let parsed: IntershardResourceType = serde_json::from_str(&serialized).unwrap();
assert_eq!(resource, parsed);
}
let serialized = serde_json::to_string(&resource).unwrap();
let parsed: IntershardResourceType = serde_json::from_str(&serialized).unwrap();
assert_eq!(resource, parsed);
}
}

#[test]
fn intershard_resources_rust_to_display_from_str_roundtrip() {
for resource in enum_iterator::all::<IntershardResourceType>() {
if resource != IntershardResourceType::__Nonexhaustive {
let string = format!("{}", resource);
let parsed = IntershardResourceType::from_str(&string).unwrap();
assert_eq!(resource, parsed);
}
let string = format!("{}", resource);
let parsed = IntershardResourceType::from_str(&string).unwrap();
assert_eq!(resource, parsed);
}
}

#[test]
fn intershard_resources_rust_vec_to_serde_json_from_serde_json_roundtrip() {
let mut resources = vec![];
for resource in enum_iterator::all::<IntershardResourceType>() {
if resource != IntershardResourceType::__Nonexhaustive {
resources.push(resource);
}
resources.push(resource);
}
let serialized = serde_json::to_string(&resources).unwrap();
let resources_reparsed: Vec<IntershardResourceType> =
Expand All @@ -924,9 +910,7 @@ mod test {
fn intershard_resources_rust_vec_to_serde_json_from_serde_json_roundtrip_via_values() {
let mut resources = vec![];
for resource in enum_iterator::all::<IntershardResourceType>() {
if resource != IntershardResourceType::__Nonexhaustive {
resources.push(resource);
}
resources.push(resource);
}
let serialized = serde_json::to_string(&resources).unwrap();
let resources_reparsed_values: Vec<serde_json::Value> =
Expand All @@ -941,31 +925,17 @@ mod test {
#[test]
fn market_resources_rust_to_serde_json_from_serde_json_roundtrip() {
for resource in enum_iterator::all::<MarketResourceType>() {
if resource != MarketResourceType::Resource(ResourceType::__Nonexhaustive)
&& resource
!= MarketResourceType::IntershardResource(
IntershardResourceType::__Nonexhaustive,
)
{
let serialized = serde_json::to_string(&resource).unwrap();
let parsed: MarketResourceType = serde_json::from_str(&serialized).unwrap();
assert_eq!(resource, parsed);
}
let serialized = serde_json::to_string(&resource).unwrap();
let parsed: MarketResourceType = serde_json::from_str(&serialized).unwrap();
assert_eq!(resource, parsed);
}
}

#[test]
fn market_resources_rust_vec_to_serde_json_from_serde_json_roundtrip() {
let mut resources = vec![];
for resource in enum_iterator::all::<MarketResourceType>() {
if resource != MarketResourceType::Resource(ResourceType::__Nonexhaustive)
&& resource
!= MarketResourceType::IntershardResource(
IntershardResourceType::__Nonexhaustive,
)
{
resources.push(resource);
}
resources.push(resource);
}
let serialized = serde_json::to_string(&resources).unwrap();
let resources_reparsed: Vec<MarketResourceType> =
Expand All @@ -977,14 +947,7 @@ mod test {
fn market_resources_rust_vec_to_serde_json_from_serde_json_roundtrip_via_values() {
let mut resources = vec![];
for resource in enum_iterator::all::<MarketResourceType>() {
if resource != MarketResourceType::Resource(ResourceType::__Nonexhaustive)
&& resource
!= MarketResourceType::IntershardResource(
IntershardResourceType::__Nonexhaustive,
)
{
resources.push(resource);
}
resources.push(resource);
}
let serialized = serde_json::to_string(&resources).unwrap();
let resources_reparsed_values: Vec<serde_json::Value> =
Expand Down

0 comments on commit 0bc6a5a

Please sign in to comment.