open_tavern/tests/macro_test.rs

28 lines
775 B
Rust

use open_tavern::game::character_sheet::EntryType;
use tavern_macros::CharacterSheet;
#[test]
fn test_macro() {
trait CharacterSheet {
fn inputs(&self) -> Vec<(String, EntryType)>;
fn fields(&self) -> Vec<(String, EntryType)>;
fn get(&self, entry: &str) -> Option<EntryType>;
fn set(&mut self, entry: &str, value: EntryType);
}
#[derive(CharacterSheet)]
struct Testy {
a: String,
#[Input("AA")]
b: String,
#[Input("BB")]
c: String,
#[Input("Strength")]
str: i32,
#[Field("Athletics")]
#[FieldExpr(self.str + (self.athletics_trained as i32) * 2)]
athletics: i32,
#[Input("Trained Athletics")]
athletics_trained: bool,
}
}