Adds more testing
Build Successful The build was successful
Gitea/epoch_forge/pipeline/head This commit looks good
Details
Build Successful The build was successful
Gitea/epoch_forge/pipeline/head This commit looks good
Details
This commit is contained in:
parent
98707eac5b
commit
a1bed93bb0
|
|
@ -0,0 +1,91 @@
|
|||
---
|
||||
source: lib_efo/src/entity/test.rs
|
||||
expression: "format!(\"{:#?}\", e)"
|
||||
---
|
||||
Entity {
|
||||
name: "",
|
||||
id: 00000000-0000-0000-0000-000000000000,
|
||||
stats: OverallStats {
|
||||
demographics: GenericStat(
|
||||
0,
|
||||
),
|
||||
population: GenericStat(
|
||||
0,
|
||||
),
|
||||
growth_rate: GenericStat(
|
||||
0,
|
||||
),
|
||||
crime: GenericStat(
|
||||
0,
|
||||
),
|
||||
happiness: GenericStat(
|
||||
0,
|
||||
),
|
||||
economy: GenericStat(
|
||||
0,
|
||||
),
|
||||
food: GenericStat(
|
||||
0,
|
||||
),
|
||||
industry: GenericStat(
|
||||
0,
|
||||
),
|
||||
science: GenericStat(
|
||||
0,
|
||||
),
|
||||
trade: GenericStat(
|
||||
0,
|
||||
),
|
||||
military: GenericStat(
|
||||
0,
|
||||
),
|
||||
army: GenericStat(
|
||||
0,
|
||||
),
|
||||
strength: GenericStat(
|
||||
0,
|
||||
),
|
||||
fortification: GenericStat(
|
||||
0,
|
||||
),
|
||||
threat: GenericStat(
|
||||
0,
|
||||
),
|
||||
infrastructure: GenericStat(
|
||||
0,
|
||||
),
|
||||
bureaucracy: GenericStat(
|
||||
0,
|
||||
),
|
||||
transportation: GenericStat(
|
||||
0,
|
||||
),
|
||||
sprawl: GenericStat(
|
||||
0,
|
||||
),
|
||||
health: GenericStat(
|
||||
4,
|
||||
),
|
||||
},
|
||||
temp_stats: None,
|
||||
metadata: MetaStats {
|
||||
position: Position(
|
||||
0,
|
||||
0,
|
||||
),
|
||||
capital: None,
|
||||
governor: None,
|
||||
faction: None,
|
||||
links: [],
|
||||
prestige: GenericStat(
|
||||
0,
|
||||
),
|
||||
},
|
||||
entity_type: Event,
|
||||
duration: Done,
|
||||
effect_nature: PermanentEffectToApply,
|
||||
effect_bounds: EffectBounds {
|
||||
min: 0,
|
||||
max: 0,
|
||||
},
|
||||
}
|
||||
|
|
@ -0,0 +1,162 @@
|
|||
---
|
||||
source: lib_efo/src/entity/test.rs
|
||||
expression: "format!(\"{:#?}\", delta2)"
|
||||
---
|
||||
Entity {
|
||||
name: "Bob",
|
||||
id: 00000000-0000-0000-0000-000000000000,
|
||||
stats: OverallStats {
|
||||
demographics: GenericStat(
|
||||
0,
|
||||
),
|
||||
population: GenericStat(
|
||||
0,
|
||||
),
|
||||
growth_rate: GenericStat(
|
||||
0,
|
||||
),
|
||||
crime: GenericStat(
|
||||
0,
|
||||
),
|
||||
happiness: GenericStat(
|
||||
0,
|
||||
),
|
||||
economy: GenericStat(
|
||||
0,
|
||||
),
|
||||
food: GenericStat(
|
||||
0,
|
||||
),
|
||||
industry: GenericStat(
|
||||
0,
|
||||
),
|
||||
science: GenericStat(
|
||||
0,
|
||||
),
|
||||
trade: GenericStat(
|
||||
0,
|
||||
),
|
||||
military: GenericStat(
|
||||
0,
|
||||
),
|
||||
army: GenericStat(
|
||||
0,
|
||||
),
|
||||
strength: GenericStat(
|
||||
0,
|
||||
),
|
||||
fortification: GenericStat(
|
||||
0,
|
||||
),
|
||||
threat: GenericStat(
|
||||
0,
|
||||
),
|
||||
infrastructure: GenericStat(
|
||||
0,
|
||||
),
|
||||
bureaucracy: GenericStat(
|
||||
0,
|
||||
),
|
||||
transportation: GenericStat(
|
||||
0,
|
||||
),
|
||||
sprawl: GenericStat(
|
||||
0,
|
||||
),
|
||||
health: GenericStat(
|
||||
0,
|
||||
),
|
||||
},
|
||||
temp_stats: Some(
|
||||
OverallStats {
|
||||
demographics: GenericStat(
|
||||
0,
|
||||
),
|
||||
population: GenericStat(
|
||||
0,
|
||||
),
|
||||
growth_rate: GenericStat(
|
||||
0,
|
||||
),
|
||||
crime: GenericStat(
|
||||
0,
|
||||
),
|
||||
happiness: GenericStat(
|
||||
0,
|
||||
),
|
||||
economy: GenericStat(
|
||||
0,
|
||||
),
|
||||
food: GenericStat(
|
||||
0,
|
||||
),
|
||||
industry: GenericStat(
|
||||
0,
|
||||
),
|
||||
science: GenericStat(
|
||||
0,
|
||||
),
|
||||
trade: GenericStat(
|
||||
0,
|
||||
),
|
||||
military: GenericStat(
|
||||
0,
|
||||
),
|
||||
army: GenericStat(
|
||||
0,
|
||||
),
|
||||
strength: GenericStat(
|
||||
0,
|
||||
),
|
||||
fortification: GenericStat(
|
||||
0,
|
||||
),
|
||||
threat: GenericStat(
|
||||
0,
|
||||
),
|
||||
infrastructure: GenericStat(
|
||||
0,
|
||||
),
|
||||
bureaucracy: GenericStat(
|
||||
0,
|
||||
),
|
||||
transportation: GenericStat(
|
||||
0,
|
||||
),
|
||||
sprawl: GenericStat(
|
||||
0,
|
||||
),
|
||||
health: GenericStat(
|
||||
0,
|
||||
),
|
||||
},
|
||||
),
|
||||
metadata: MetaStats {
|
||||
position: Position(
|
||||
0,
|
||||
0,
|
||||
),
|
||||
capital: None,
|
||||
governor: None,
|
||||
faction: Some(
|
||||
FactionId(
|
||||
5,
|
||||
),
|
||||
),
|
||||
links: [
|
||||
TownId(
|
||||
6,
|
||||
),
|
||||
],
|
||||
prestige: GenericStat(
|
||||
0,
|
||||
),
|
||||
},
|
||||
entity_type: Town,
|
||||
duration: Permanent,
|
||||
effect_nature: Recurring,
|
||||
effect_bounds: EffectBounds {
|
||||
min: 0,
|
||||
max: 0,
|
||||
},
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
---
|
||||
source: lib_efo/src/entity/test.rs
|
||||
expression: "format!(\"{:#?}\", delta2)"
|
||||
---
|
||||
MetaStats {
|
||||
position: Position(
|
||||
0,
|
||||
0,
|
||||
),
|
||||
capital: None,
|
||||
governor: None,
|
||||
faction: Some(
|
||||
FactionId(
|
||||
33,
|
||||
),
|
||||
),
|
||||
links: [
|
||||
TownId(
|
||||
55,
|
||||
),
|
||||
],
|
||||
prestige: GenericStat(
|
||||
0,
|
||||
),
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
---
|
||||
source: lib_efo/src/entity/test.rs
|
||||
expression: "format!(\"{:#?}\", delta3)"
|
||||
---
|
||||
MetaStats {
|
||||
position: Position(
|
||||
0,
|
||||
0,
|
||||
),
|
||||
capital: None,
|
||||
governor: None,
|
||||
faction: Some(
|
||||
FactionId(
|
||||
33,
|
||||
),
|
||||
),
|
||||
links: [
|
||||
TownId(
|
||||
55,
|
||||
),
|
||||
],
|
||||
prestige: GenericStat(
|
||||
0,
|
||||
),
|
||||
}
|
||||
|
|
@ -0,0 +1,93 @@
|
|||
---
|
||||
source: lib_efo/src/entity/test.rs
|
||||
expression: "format!(\"{:#?}\", e)"
|
||||
---
|
||||
Entity {
|
||||
name: "",
|
||||
id: 00000000-0000-0000-0000-000000000000,
|
||||
stats: OverallStats {
|
||||
demographics: GenericStat(
|
||||
0,
|
||||
),
|
||||
population: GenericStat(
|
||||
0,
|
||||
),
|
||||
growth_rate: GenericStat(
|
||||
0,
|
||||
),
|
||||
crime: GenericStat(
|
||||
0,
|
||||
),
|
||||
happiness: GenericStat(
|
||||
0,
|
||||
),
|
||||
economy: GenericStat(
|
||||
0,
|
||||
),
|
||||
food: GenericStat(
|
||||
0,
|
||||
),
|
||||
industry: GenericStat(
|
||||
0,
|
||||
),
|
||||
science: GenericStat(
|
||||
0,
|
||||
),
|
||||
trade: GenericStat(
|
||||
0,
|
||||
),
|
||||
military: GenericStat(
|
||||
0,
|
||||
),
|
||||
army: GenericStat(
|
||||
0,
|
||||
),
|
||||
strength: GenericStat(
|
||||
0,
|
||||
),
|
||||
fortification: GenericStat(
|
||||
0,
|
||||
),
|
||||
threat: GenericStat(
|
||||
0,
|
||||
),
|
||||
infrastructure: GenericStat(
|
||||
0,
|
||||
),
|
||||
bureaucracy: GenericStat(
|
||||
0,
|
||||
),
|
||||
transportation: GenericStat(
|
||||
0,
|
||||
),
|
||||
sprawl: GenericStat(
|
||||
0,
|
||||
),
|
||||
health: GenericStat(
|
||||
0,
|
||||
),
|
||||
},
|
||||
temp_stats: None,
|
||||
metadata: MetaStats {
|
||||
position: Position(
|
||||
0,
|
||||
0,
|
||||
),
|
||||
capital: None,
|
||||
governor: None,
|
||||
faction: None,
|
||||
links: [],
|
||||
prestige: GenericStat(
|
||||
0,
|
||||
),
|
||||
},
|
||||
entity_type: Event,
|
||||
duration: Duration(
|
||||
33,
|
||||
),
|
||||
effect_nature: PermanentEffectToApply,
|
||||
effect_bounds: EffectBounds {
|
||||
min: 0,
|
||||
max: 0,
|
||||
},
|
||||
}
|
||||
|
|
@ -0,0 +1,91 @@
|
|||
---
|
||||
source: lib_efo/src/entity/test.rs
|
||||
expression: "format!(\"{:#?}\", e)"
|
||||
---
|
||||
Entity {
|
||||
name: "",
|
||||
id: 00000000-0000-0000-0000-000000000000,
|
||||
stats: OverallStats {
|
||||
demographics: GenericStat(
|
||||
0,
|
||||
),
|
||||
population: GenericStat(
|
||||
0,
|
||||
),
|
||||
growth_rate: GenericStat(
|
||||
0,
|
||||
),
|
||||
crime: GenericStat(
|
||||
0,
|
||||
),
|
||||
happiness: GenericStat(
|
||||
0,
|
||||
),
|
||||
economy: GenericStat(
|
||||
0,
|
||||
),
|
||||
food: GenericStat(
|
||||
0,
|
||||
),
|
||||
industry: GenericStat(
|
||||
0,
|
||||
),
|
||||
science: GenericStat(
|
||||
0,
|
||||
),
|
||||
trade: GenericStat(
|
||||
0,
|
||||
),
|
||||
military: GenericStat(
|
||||
0,
|
||||
),
|
||||
army: GenericStat(
|
||||
0,
|
||||
),
|
||||
strength: GenericStat(
|
||||
0,
|
||||
),
|
||||
fortification: GenericStat(
|
||||
0,
|
||||
),
|
||||
threat: GenericStat(
|
||||
0,
|
||||
),
|
||||
infrastructure: GenericStat(
|
||||
0,
|
||||
),
|
||||
bureaucracy: GenericStat(
|
||||
0,
|
||||
),
|
||||
transportation: GenericStat(
|
||||
0,
|
||||
),
|
||||
sprawl: GenericStat(
|
||||
0,
|
||||
),
|
||||
health: GenericStat(
|
||||
0,
|
||||
),
|
||||
},
|
||||
temp_stats: None,
|
||||
metadata: MetaStats {
|
||||
position: Position(
|
||||
0,
|
||||
0,
|
||||
),
|
||||
capital: None,
|
||||
governor: None,
|
||||
faction: None,
|
||||
links: [],
|
||||
prestige: GenericStat(
|
||||
0,
|
||||
),
|
||||
},
|
||||
entity_type: Event,
|
||||
duration: Done,
|
||||
effect_nature: PermanentEffectApplied,
|
||||
effect_bounds: EffectBounds {
|
||||
min: 0,
|
||||
max: 0,
|
||||
},
|
||||
}
|
||||
|
|
@ -0,0 +1,91 @@
|
|||
---
|
||||
source: lib_efo/src/entity/test.rs
|
||||
expression: "format!(\"{:#?}\", e)"
|
||||
---
|
||||
Entity {
|
||||
name: "",
|
||||
id: 00000000-0000-0000-0000-000000000000,
|
||||
stats: OverallStats {
|
||||
demographics: GenericStat(
|
||||
0,
|
||||
),
|
||||
population: GenericStat(
|
||||
0,
|
||||
),
|
||||
growth_rate: GenericStat(
|
||||
0,
|
||||
),
|
||||
crime: GenericStat(
|
||||
0,
|
||||
),
|
||||
happiness: GenericStat(
|
||||
0,
|
||||
),
|
||||
economy: GenericStat(
|
||||
0,
|
||||
),
|
||||
food: GenericStat(
|
||||
0,
|
||||
),
|
||||
industry: GenericStat(
|
||||
0,
|
||||
),
|
||||
science: GenericStat(
|
||||
0,
|
||||
),
|
||||
trade: GenericStat(
|
||||
0,
|
||||
),
|
||||
military: GenericStat(
|
||||
0,
|
||||
),
|
||||
army: GenericStat(
|
||||
0,
|
||||
),
|
||||
strength: GenericStat(
|
||||
0,
|
||||
),
|
||||
fortification: GenericStat(
|
||||
0,
|
||||
),
|
||||
threat: GenericStat(
|
||||
0,
|
||||
),
|
||||
infrastructure: GenericStat(
|
||||
0,
|
||||
),
|
||||
bureaucracy: GenericStat(
|
||||
0,
|
||||
),
|
||||
transportation: GenericStat(
|
||||
0,
|
||||
),
|
||||
sprawl: GenericStat(
|
||||
0,
|
||||
),
|
||||
health: GenericStat(
|
||||
0,
|
||||
),
|
||||
},
|
||||
temp_stats: None,
|
||||
metadata: MetaStats {
|
||||
position: Position(
|
||||
0,
|
||||
0,
|
||||
),
|
||||
capital: None,
|
||||
governor: None,
|
||||
faction: None,
|
||||
links: [],
|
||||
prestige: GenericStat(
|
||||
0,
|
||||
),
|
||||
},
|
||||
entity_type: Event,
|
||||
duration: Done,
|
||||
effect_nature: PermanentEffectToApply,
|
||||
effect_bounds: EffectBounds {
|
||||
min: 33,
|
||||
max: 33,
|
||||
},
|
||||
}
|
||||
|
|
@ -14,10 +14,6 @@ use crate::Displayable;
|
|||
use insta::assert_snapshot;
|
||||
use uuid::Uuid;
|
||||
|
||||
/// The same structs & enums that the original crate exports - adjust the names
|
||||
/// if your crate uses different identifiers.
|
||||
|
||||
// ---------- EntityDuration ----------
|
||||
#[test]
|
||||
fn entity_duration_parses_permanent_and_done() {
|
||||
assert_eq!(
|
||||
|
|
@ -122,7 +118,6 @@ fn entity_duration_returns_error_on_invalid_inputs() {
|
|||
}
|
||||
}
|
||||
|
||||
// ---------- EffectBounds ----------
|
||||
#[test]
|
||||
fn effect_bounds_parses_colon_and_dash_separated_values() {
|
||||
// colon
|
||||
|
|
@ -186,7 +181,6 @@ fn effect_bounds_returns_error_on_invalid_inputs() {
|
|||
}
|
||||
}
|
||||
|
||||
// ---------- EntityIdentifier ----------
|
||||
#[test]
|
||||
fn entity_identifier_parses_id_and_name() {
|
||||
// id
|
||||
|
|
@ -228,23 +222,10 @@ fn entity_identifier_errors_on_invalid_id() {
|
|||
// }
|
||||
}
|
||||
|
||||
// #[test]
|
||||
// fn entity_identifier_treats_non_prefixed_@ as name() {
|
||||
// // leading space -> part of the name
|
||||
// let name = EntityIdentifier::from_str(" @uuid").unwrap();
|
||||
// match name {
|
||||
// EntityIdentifier::Name(n) => assert_eq!(n, " @uuid"),
|
||||
// _ => panic!("Expected Name variant"),
|
||||
// }
|
||||
// }
|
||||
//
|
||||
|
||||
/// Disable coloured output so that snapshots are stable (no ANSI codes).
|
||||
fn init_snapshot_env() {
|
||||
colored::control::set_override(false);
|
||||
}
|
||||
|
||||
/// Build a fully-featured entity (capital, governor, prestige > 0).
|
||||
fn full_entity() -> Entity {
|
||||
Entity {
|
||||
id: Uuid::from_u128_le(12),
|
||||
|
|
@ -421,13 +402,13 @@ fn snapshot_entity_delta() {
|
|||
|
||||
// Compute the delta
|
||||
let mut delta = e1.delta(&e2);
|
||||
let mut delta2 = e2.delta(&e2);
|
||||
delta.id = Uuid::nil();
|
||||
delta2.id = Uuid::nil();
|
||||
assert_snapshot!(format!("{:#?}", delta));
|
||||
assert_snapshot!(format!("{:#?}", delta2));
|
||||
}
|
||||
|
||||
/// ------------------------------------------------------------------
|
||||
/// 3. `Diffable` - `Option<OverallStats>`
|
||||
/// ------------------------------------------------------------------
|
||||
#[test]
|
||||
fn snapshot_option_stats_delta() {
|
||||
init_snapshot_env();
|
||||
|
|
@ -444,9 +425,6 @@ fn snapshot_option_stats_delta() {
|
|||
assert_snapshot!(format!("{:#?}", delta));
|
||||
}
|
||||
|
||||
/// ------------------------------------------------------------------
|
||||
/// 4. `Diffable` - `MetaStats`
|
||||
/// ------------------------------------------------------------------
|
||||
#[test]
|
||||
fn snapshot_meta_stats_delta() {
|
||||
init_snapshot_env();
|
||||
|
|
@ -468,8 +446,64 @@ fn snapshot_meta_stats_delta() {
|
|||
links: vec![TownId::from(55)],
|
||||
prestige: stats::GenericStat(1),
|
||||
};
|
||||
let meta3 = MetaStats {
|
||||
position: Position::from((44, 555)),
|
||||
capital: None,
|
||||
governor: Some(stats::CharacterId(400)),
|
||||
faction: Some(stats::FactionId(33)),
|
||||
links: vec![TownId::from(55)],
|
||||
prestige: stats::GenericStat(1),
|
||||
};
|
||||
|
||||
let delta = meta1.delta(&meta2);
|
||||
let delta2 = meta2.delta(&meta3);
|
||||
let delta3 = meta3.delta(&meta3);
|
||||
|
||||
assert_snapshot!(format!("{:#?}", delta));
|
||||
assert_snapshot!(format!("{:#?}", delta2));
|
||||
assert_snapshot!(format!("{:#?}", delta3));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn snapshot_delta_stat_positive() {
|
||||
init_snapshot_env();
|
||||
|
||||
let mut e = Entity::default();
|
||||
e.delta_stat(StatPair::from_str("health:4").unwrap());
|
||||
e.id = Uuid::nil();
|
||||
|
||||
assert_snapshot!(format!("{:#?}", e));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn snapshot_modify_duration() {
|
||||
init_snapshot_env();
|
||||
|
||||
let mut e = Entity::default();
|
||||
e.modify_duration(EntityDuration::Duration(33));
|
||||
e.id = Uuid::nil();
|
||||
|
||||
assert_snapshot!(format!("{:#?}", e));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn snapshot_modify_effect_application() {
|
||||
init_snapshot_env();
|
||||
|
||||
let mut e = Entity::default();
|
||||
e.modify_effect_application(EffectApplication::PermanentEffectApplied);
|
||||
e.id = Uuid::nil();
|
||||
|
||||
assert_snapshot!(format!("{:#?}", e));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn snapshot_modify_effect_bounds() {
|
||||
init_snapshot_env();
|
||||
|
||||
let mut e = Entity::default();
|
||||
e.modify_effect_bounds(EffectBounds::from(33..33));
|
||||
e.id = Uuid::nil();
|
||||
|
||||
assert_snapshot!(format!("{:#?}", e));
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue