mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-20 03:18:06 +08:00
Add tests to the Ellipse, Artboard, and Fill tools (#2181)
* Add ellipse tests * Add tests for fill tool and re-enable some other tests * Code review * Fix Rust crate advisory --------- Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
@@ -19,6 +19,8 @@ use std::marker::PhantomData;
|
||||
use std::str::FromStr;
|
||||
pub use std::sync::Arc;
|
||||
|
||||
pub struct TaggedValueTypeError;
|
||||
|
||||
/// Macro to generate the tagged value enum.
|
||||
macro_rules! tagged_value {
|
||||
($ ($( #[$meta:meta] )* $identifier:ident ($ty:ty) ),* $(,)?) => {
|
||||
@@ -111,6 +113,26 @@ macro_rules! tagged_value {
|
||||
Self::from_type(input).unwrap_or(TaggedValue::None)
|
||||
}
|
||||
}
|
||||
|
||||
$(
|
||||
impl From<$ty> for TaggedValue {
|
||||
fn from(value: $ty) -> Self {
|
||||
Self::$identifier(value)
|
||||
}
|
||||
}
|
||||
)*
|
||||
|
||||
$(
|
||||
impl<'a> TryFrom<&'a TaggedValue> for &'a $ty {
|
||||
type Error = TaggedValueTypeError;
|
||||
fn try_from(value: &'a TaggedValue) -> Result<Self, Self::Error> {
|
||||
match value{
|
||||
TaggedValue::$identifier(value) => Ok(value),
|
||||
_ => Err(TaggedValueTypeError),
|
||||
}
|
||||
}
|
||||
}
|
||||
)*
|
||||
};
|
||||
}
|
||||
|
||||
@@ -128,6 +150,7 @@ tagged_value! {
|
||||
#[cfg_attr(feature = "serde", serde(deserialize_with = "graphene_core::migrate_artboard_group"))]
|
||||
ArtboardGroup(graphene_core::ArtboardGroupTable),
|
||||
GraphicElement(graphene_core::GraphicElement),
|
||||
Artboard(graphene_core::Artboard),
|
||||
String(String),
|
||||
U32(u32),
|
||||
U64(u64),
|
||||
|
||||
Reference in New Issue
Block a user