update tests

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller 2025-01-14 16:49:16 +01:00
parent f5adbcf1aa
commit 476bd7af6b
3 changed files with 22 additions and 0 deletions

View File

@ -21,6 +21,13 @@ enum AnEnum {
ResultB,
}
#[derive(Debug, Deserialize, Serialize)]
#[serde(rename_all = "kebab-case")]
enum TaggedEnum {
Something(String),
Another(i32, i32),
}
#[perlmod::package(
name = "RSPM::Foo142",
lib = "perlmod_test",
@ -33,6 +40,7 @@ mod export {
use perlmod::Value;
use super::AnEnum;
use super::TaggedEnum;
fn loaded() {
println!("<loaded>");
@ -80,6 +88,14 @@ mod export {
})
}
#[export]
fn test_enums2(data: TaggedEnum) -> TaggedEnum {
match data {
TaggedEnum::Something(word) => TaggedEnum::Something(format!("{word}.")),
TaggedEnum::Another(n, m) => TaggedEnum::Another(n + 1, m * 2),
}
}
#[export]
fn test_trailing_optional(first: u32, second: Option<u32>) {
println!("{first:?}, {second:?}");

View File

@ -130,3 +130,7 @@ my $err = $@;
die "test_deserialized_error error is not a hash\n" if ref($err) ne 'HASH';
die "structured error has invalid fields\n" if join(',', sort(keys(%$err))) ne 'a,b';
print('error type: { a: ', $err->{a}, ', b: ', $err->{b}, " }\n");
my $a = RSPM::Foo142::test_enums2({ something => "hello" });
print(join(', ', keys %$a), "\n");
print($a->{something}, "\n");

View File

@ -47,3 +47,5 @@ Testing optional parameters
Substring test
[OneTwoThree] [Two]
error type: { a: first, b: second }
something
hello.