Skip to content

Conversation

@zhan7236
Copy link
Contributor

What does this PR do?

This PR adds cross-language (xlang) tests for Union types in XlangTestBase.java as requested in #3062.

Changes:

  • Add `StructWithUnionFields` class with Union through Union6 fields for testing Union types as struct fields
  • Add `testStructWithUnionFields()` test method to verify serialization/deserialization of structs containing Union fields
  • Add `testTopLevelUnion()` test method to verify serialization/deserialization of top-level Union objects
  • Skip Union tests in `GoXlangTest` and `RustXlangTest` with `SkipException` (Union types not yet supported in Go/Rust)

Test Details:

  1. testStructWithUnionFields: Creates a struct with Union1-6 fields containing different value types (Integer, String, Double, Boolean, Long, Float), serializes and deserializes it
  2. testTopLevelUnion: Tests serializing Union objects directly (not as struct fields), including both int and string variants

Related issues

Follow-up to #3062 (Java Union type support)
Relates to #3030 (Union type support tracking issue)

Does this PR introduce any user-facing change?

No, this PR only adds tests.

Benchmark

N/A - test-only changes

- Add StructWithUnionFields class with Union through Union6 fields
- Add testStructWithUnionFields() to test Union types as struct fields
- Add testTopLevelUnion() to test serializing top-level Union objects
- Skip Union tests in GoXlangTest and RustXlangTest (not yet supported)
/** Struct containing Union fields of different arities (Union through Union6). */
@Data
public static class StructWithUnionFields {
public org.apache.fory.type.union.Union union;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add imports for those types instead of using qualified class

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.

@Test
@Override
public void testStructWithUnionFields() throws java.io.IOException {
throw new SkipException("Union types not yet supported in C++");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add cpp tests in cpp/fory/serialization/xlang_test_main.cc?

Only added cpp tests, and make it pass, we can ensure union xlang serialization is OK

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants