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:
James Lindsay
2025-03-07 02:13:15 +00:00
committed by GitHub
parent 1190e82322
commit b171eeba84
22 changed files with 1097 additions and 236 deletions

View File

@@ -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),