Updates coverage and adds some tests
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
5541e657b8
commit
3bda2fa258
|
|
@ -1,8 +1,8 @@
|
|||
[last_run_clean]
|
||||
run_status = "Success"
|
||||
lines_parsed = 98
|
||||
coverage = 52.9
|
||||
lines_parsed = 102
|
||||
coverage = 47.96
|
||||
|
||||
[last_run_clean.run_duration]
|
||||
secs = 25
|
||||
nanos = 607715147
|
||||
secs = 26
|
||||
nanos = 496094925
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="122" height="18" role="img" aria-label="test-coverage: 53%"><title>test-coverage: 53%</title><linearGradient id="bms-78c5016245f6e360" x2="0" y2="100%"><stop offset="0" stop-color="#fff" stop-opacity=".7"/><stop offset=".1" stop-color="#aaa" stop-opacity=".1"/><stop offset=".9" stop-color="#000" stop-opacity=".3"/><stop offset="1" stop-color="#000" stop-opacity=".5"/></linearGradient><clipPath id="bmr-78c5016245f6e360"><rect width="122" height="18" rx="4" fill="#fff"/></clipPath><g clip-path="url(#bmr-78c5016245f6e360)"><rect width="87" height="18" fill="#555"/><rect x="87" width="35" height="18" fill="#97ca00"/><rect width="122" height="18" fill="url(#bms-78c5016245f6e360)"/></g><g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110"><text aria-hidden="true" x="445" y="140" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="770">test-coverage</text><text x="445" y="130" transform="scale(.1)" fill="#fff" textLength="770">test-coverage</text><text aria-hidden="true" x="1035" y="140" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="250">53%</text><text x="1035" y="130" transform="scale(.1)" fill="#fff" textLength="250">53%</text></g></svg>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="122" height="18" role="img" aria-label="test-coverage: 48%"><title>test-coverage: 48%</title><linearGradient id="bms-ccea4f7561c6b24b" x2="0" y2="100%"><stop offset="0" stop-color="#fff" stop-opacity=".7"/><stop offset=".1" stop-color="#aaa" stop-opacity=".1"/><stop offset=".9" stop-color="#000" stop-opacity=".3"/><stop offset="1" stop-color="#000" stop-opacity=".5"/></linearGradient><clipPath id="bmr-ccea4f7561c6b24b"><rect width="122" height="18" rx="4" fill="#fff"/></clipPath><g clip-path="url(#bmr-ccea4f7561c6b24b)"><rect width="87" height="18" fill="#555"/><rect x="87" width="35" height="18" fill="#97ca00"/><rect width="122" height="18" fill="url(#bms-ccea4f7561c6b24b)"/></g><g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110"><text aria-hidden="true" x="445" y="140" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="770">test-coverage</text><text x="445" y="130" transform="scale(.1)" fill="#fff" textLength="770">test-coverage</text><text aria-hidden="true" x="1035" y="140" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="250">48%</text><text x="1035" y="130" transform="scale(.1)" fill="#fff" textLength="250">48%</text></g></svg>
|
||||
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
|
|
@ -13,7 +13,6 @@
|
|||
|
||||
use std::str::FromStr;
|
||||
|
||||
use clap::ValueEnum;
|
||||
use derive_more::{Add, Display, Sub};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use uuid::Uuid;
|
||||
|
|
@ -95,7 +94,7 @@ pub struct EffectBounds {
|
|||
}
|
||||
|
||||
/// How the entity's effect is applied over time.
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, Default, ValueEnum)]
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
|
||||
pub enum EffectApplication {
|
||||
/// Repeatedly applied every turn while the entity is present.
|
||||
Recurring,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,14 @@
|
|||
---
|
||||
source: lib_efo/src/entity/test.rs
|
||||
expression: collect
|
||||
---
|
||||
|
||||
recurring = Ok(Recurring)
|
||||
when_present_wh = Ok(WhenPresent)
|
||||
when_present_present = Ok(WhenPresent)
|
||||
when_present_toap = Ok(WhenPresent)
|
||||
when_present_appl = Ok(WhenPresent)
|
||||
permanent_effect_applied_done = Ok(PermanentEffectApplied)
|
||||
permanent_effect_applied_ok = Ok(PermanentEffectApplied)
|
||||
permanent_effect_to_apply = Ok(PermanentEffectToApply)
|
||||
parse_error = Err(ParsingArgument { argument_parsed: "unknown", while_parsing: "EffectApplication" })
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
---
|
||||
source: lib_efo/src/entity/test.rs
|
||||
expression: result
|
||||
---
|
||||
Ok(
|
||||
Recurring,
|
||||
)
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
---
|
||||
source: lib_efo/src/entity/test.rs
|
||||
expression: result
|
||||
---
|
||||
Ok(
|
||||
WhenPresent,
|
||||
)
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
// tests/mod.rs - or put this inside your crate's tests module
|
||||
#![allow(unused_imports)]
|
||||
|
||||
use std::arch::x86_64::_mm256_mask_inserti64x2;
|
||||
use std::str::FromStr;
|
||||
|
||||
use crate::entity::{EffectApplication, EffectBounds, Entity, EntityDuration, EntityIdentifier};
|
||||
|
|
@ -12,7 +13,7 @@ use std::io::Write;
|
|||
|
||||
use super::*;
|
||||
use crate::Displayable;
|
||||
use insta::assert_snapshot;
|
||||
use insta::{assert_debug_snapshot, assert_snapshot};
|
||||
use uuid::Uuid;
|
||||
|
||||
#[test]
|
||||
|
|
@ -566,3 +567,29 @@ fn test_rng() {
|
|||
Entity::create_rng(&EntityType::Event, &crate::utils::RngLevel::Mixed).unwrap();
|
||||
Entity::create_rng(&EntityType::Event, &crate::utils::RngLevel::Flawed).unwrap();
|
||||
}
|
||||
|
||||
/// All the inputs we want to test, in the same order the original
|
||||
/// `match` evaluates them. The key is the snapshot name, the
|
||||
/// value is the input string.
|
||||
const TEST_CASES: &[(&str, &str)] = &[
|
||||
("recurring", "re"),
|
||||
("when_present_wh", "wh"),
|
||||
("when_present_present", "present"),
|
||||
("when_present_toap", "toap"),
|
||||
("when_present_appl", "appl"),
|
||||
("permanent_effect_applied_done", "done"),
|
||||
("permanent_effect_applied_ok", "ok"),
|
||||
("permanent_effect_to_apply", "todo"),
|
||||
("parse_error", "unknown"),
|
||||
];
|
||||
|
||||
#[test]
|
||||
fn effect_application_from_str_snapshots() {
|
||||
let mut collect = String::new();
|
||||
for (snapshot_name, input) in TEST_CASES {
|
||||
let result: Result<EffectApplication, EpochError> =
|
||||
<crate::entity::EffectApplication>::from_str(input);
|
||||
collect = format!("{}\n{} = {:?}", collect, snapshot_name, result);
|
||||
}
|
||||
assert_snapshot!(collect);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -391,7 +391,6 @@ pub struct MetaStats {
|
|||
|
||||
/// UIDs of all entities the entity is linked to (roads, trade routes,
|
||||
/// alliances, war declarations, etc.).
|
||||
// TODO: Type this vector, with a smart type: (Uuid, EntityType)
|
||||
pub links: Vec<TypedLink>,
|
||||
|
||||
/// Prestige / reputation of the entity in the eyes of the empire
|
||||
|
|
|
|||
Loading…
Reference in New Issue