Skip to content

Commit

Permalink
Hygiene integration test expansion
Browse files Browse the repository at this point in the history
This test was checking only the most basic scenario: a structure
that is serialized / deserialized by name matching, and has no field
attributes. Adding more advanced scenarios uncovered many hygiene issues
in the macros - those issues were fixed in previous commits.
  • Loading branch information
Lorak-mmk committed Jan 22, 2025
1 parent 8afea4c commit e87f598
Showing 1 changed file with 144 additions and 0 deletions.
144 changes: 144 additions & 0 deletions scylla/tests/integration/hygiene.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,150 @@ macro_rules! test_crate {
assert_eq!(value_with_same_layout, deserialized_value);
}
}

// Test attributes for value struct with name flavor
#[derive(
_scylla::macros::DeserializeValue, _scylla::macros::SerializeValue, PartialEq, Debug,
)]
#[scylla(crate = _scylla)]
struct TestStructByName {
a: ::core::primitive::i32,
#[scylla(allow_missing)]
b: ::core::primitive::i32,
#[scylla(default_when_null)]
c: ::core::primitive::i32,
#[scylla(skip)]
d: ::core::primitive::i32,
#[scylla(rename = "f")]
e: ::core::primitive::i32,
g: ::core::primitive::i32,
}

// Test attributes for value struct with strict name flavor
#[derive(
_scylla::macros::DeserializeValue, _scylla::macros::SerializeValue, PartialEq, Debug,
)]
#[scylla(crate = _scylla, forbid_excess_udt_fields)]
struct TestStructByNameStrict {
a: ::core::primitive::i32,
#[scylla(allow_missing)]
b: ::core::primitive::i32,
#[scylla(default_when_null)]
c: ::core::primitive::i32,
#[scylla(skip)]
d: ::core::primitive::i32,
#[scylla(rename = "f")]
e: ::core::primitive::i32,
g: ::core::primitive::i32,
}

// Test attributes for value struct with ordered flavor
#[derive(
_scylla::macros::DeserializeValue, _scylla::macros::SerializeValue, PartialEq, Debug,
)]
#[scylla(crate = _scylla, flavor = "enforce_order")]
struct TestStructOrdered {
a: ::core::primitive::i32,
#[scylla(allow_missing)]
b: ::core::primitive::i32,
#[scylla(default_when_null)]
c: ::core::primitive::i32,
#[scylla(skip)]
d: ::core::primitive::i32,
#[scylla(rename = "f")]
e: ::core::primitive::i32,
g: ::core::primitive::i32,
}

// Test attributes for value struct with strict ordered flavor
#[derive(
_scylla::macros::DeserializeValue, _scylla::macros::SerializeValue, PartialEq, Debug,
)]
#[scylla(crate = _scylla, flavor = "enforce_order", forbid_excess_udt_fields)]
struct TestStructOrderedStrict {
a: ::core::primitive::i32,
#[scylla(allow_missing)]
b: ::core::primitive::i32,
#[scylla(default_when_null)]
c: ::core::primitive::i32,
#[scylla(skip)]
d: ::core::primitive::i32,
#[scylla(rename = "f")]
e: ::core::primitive::i32,
g: ::core::primitive::i32,
}

// Test attributes for value struct with ordered flavor and skipped name checks
#[derive(
_scylla::macros::DeserializeValue, _scylla::macros::SerializeValue, PartialEq, Debug,
)]
#[scylla(crate = _scylla, flavor = "enforce_order", skip_name_checks)]
struct TestStructOrderedSkipped {
a: ::core::primitive::i32,
b: ::core::primitive::i32,
#[scylla(default_when_null)]
c: ::core::primitive::i32,
d: ::core::primitive::i32,
#[scylla(skip)]
e: ::core::primitive::i32,
#[scylla(allow_missing)]
g: ::core::primitive::i32,
}

// Test attributes for value struct with strict ordered flavor and skipped name checks
#[derive(
_scylla::macros::DeserializeValue, _scylla::macros::SerializeValue, PartialEq, Debug,
)]
#[scylla(crate = _scylla, flavor = "enforce_order", skip_name_checks, forbid_excess_udt_fields)]
struct TestStructOrderedStrictSkipped {
a: ::core::primitive::i32,
b: ::core::primitive::i32,
#[scylla(default_when_null)]
c: ::core::primitive::i32,
d: ::core::primitive::i32,
#[scylla(skip)]
e: ::core::primitive::i32,
#[scylla(allow_missing)]
g: ::core::primitive::i32,
}

// Test attributes for row struct with name flavor
#[derive(
_scylla::macros::DeserializeRow, _scylla::macros::SerializeRow, PartialEq, Debug,
)]
#[scylla(crate = _scylla)]
struct TestRowByName {
#[scylla(skip)]
a: ::core::primitive::i32,
#[scylla(rename = "f")]
b: ::core::primitive::i32,
c: ::core::primitive::i32,
}

// Test attributes for row struct with ordered flavor
#[derive(
_scylla::macros::DeserializeRow, _scylla::macros::SerializeRow, PartialEq, Debug,
)]
#[scylla(crate = _scylla, flavor = "enforce_order")]
struct TestRowByOrder {
#[scylla(skip)]
a: ::core::primitive::i32,
#[scylla(rename = "f")]
b: ::core::primitive::i32,
c: ::core::primitive::i32,
}

// Test attributes for row struct with ordered flavor and skipped name checks
#[derive(
_scylla::macros::DeserializeRow, _scylla::macros::SerializeRow, PartialEq, Debug,
)]
#[scylla(crate = _scylla, flavor = "enforce_order", skip_name_checks)]
struct TestRowByOrderSkipped {
#[scylla(skip)]
a: ::core::primitive::i32,
b: ::core::primitive::i32,
c: ::core::primitive::i32,
}
};
}

Expand Down

0 comments on commit e87f598

Please sign in to comment.