avrotize 2.21.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- avrotize/__init__.py +66 -0
- avrotize/__main__.py +6 -0
- avrotize/_version.py +34 -0
- avrotize/asn1toavro.py +160 -0
- avrotize/avrotize.py +152 -0
- avrotize/avrotocpp/CMakeLists.txt.jinja +77 -0
- avrotize/avrotocpp/build.bat.jinja +7 -0
- avrotize/avrotocpp/build.sh.jinja +7 -0
- avrotize/avrotocpp/dataclass_body.jinja +108 -0
- avrotize/avrotocpp/vcpkg.json.jinja +21 -0
- avrotize/avrotocpp.py +483 -0
- avrotize/avrotocsharp/README.md.jinja +166 -0
- avrotize/avrotocsharp/class_test.cs.jinja +266 -0
- avrotize/avrotocsharp/dataclass_core.jinja +293 -0
- avrotize/avrotocsharp/enum_test.cs.jinja +20 -0
- avrotize/avrotocsharp/project.csproj.jinja +30 -0
- avrotize/avrotocsharp/project.sln.jinja +34 -0
- avrotize/avrotocsharp/run_coverage.ps1.jinja +98 -0
- avrotize/avrotocsharp/run_coverage.sh.jinja +149 -0
- avrotize/avrotocsharp/testproject.csproj.jinja +19 -0
- avrotize/avrotocsharp.py +1180 -0
- avrotize/avrotocsv.py +121 -0
- avrotize/avrotodatapackage.py +173 -0
- avrotize/avrotodb.py +1383 -0
- avrotize/avrotogo/go_enum.jinja +12 -0
- avrotize/avrotogo/go_helpers.jinja +31 -0
- avrotize/avrotogo/go_struct.jinja +151 -0
- avrotize/avrotogo/go_test.jinja +47 -0
- avrotize/avrotogo/go_union.jinja +38 -0
- avrotize/avrotogo.py +476 -0
- avrotize/avrotographql.py +197 -0
- avrotize/avrotoiceberg.py +210 -0
- avrotize/avrotojava/class_test.java.jinja +212 -0
- avrotize/avrotojava/enum_test.java.jinja +21 -0
- avrotize/avrotojava/testproject.pom.jinja +54 -0
- avrotize/avrotojava.py +2156 -0
- avrotize/avrotojs.py +250 -0
- avrotize/avrotojsons.py +481 -0
- avrotize/avrotojstruct.py +345 -0
- avrotize/avrotokusto.py +364 -0
- avrotize/avrotomd/README.md.jinja +49 -0
- avrotize/avrotomd.py +137 -0
- avrotize/avrotools.py +168 -0
- avrotize/avrotoparquet.py +208 -0
- avrotize/avrotoproto.py +359 -0
- avrotize/avrotopython/dataclass_core.jinja +241 -0
- avrotize/avrotopython/enum_core.jinja +87 -0
- avrotize/avrotopython/pyproject_toml.jinja +18 -0
- avrotize/avrotopython/test_class.jinja +97 -0
- avrotize/avrotopython/test_enum.jinja +23 -0
- avrotize/avrotopython.py +626 -0
- avrotize/avrotorust/dataclass_enum.rs.jinja +74 -0
- avrotize/avrotorust/dataclass_struct.rs.jinja +204 -0
- avrotize/avrotorust/dataclass_union.rs.jinja +105 -0
- avrotize/avrotorust.py +435 -0
- avrotize/avrotots/class_core.ts.jinja +140 -0
- avrotize/avrotots/class_test.ts.jinja +77 -0
- avrotize/avrotots/enum_core.ts.jinja +46 -0
- avrotize/avrotots/gitignore.jinja +34 -0
- avrotize/avrotots/index.ts.jinja +0 -0
- avrotize/avrotots/package.json.jinja +23 -0
- avrotize/avrotots/tsconfig.json.jinja +21 -0
- avrotize/avrotots.py +687 -0
- avrotize/avrotoxsd.py +344 -0
- avrotize/cddltostructure.py +1841 -0
- avrotize/commands.json +3496 -0
- avrotize/common.py +834 -0
- avrotize/constants.py +87 -0
- avrotize/csvtoavro.py +132 -0
- avrotize/datapackagetoavro.py +76 -0
- avrotize/dependencies/cpp/vcpkg/vcpkg.json +19 -0
- avrotize/dependencies/cs/net90/dependencies.csproj +29 -0
- avrotize/dependencies/go/go121/go.mod +6 -0
- avrotize/dependencies/java/jdk21/pom.xml +91 -0
- avrotize/dependencies/python/py312/requirements.txt +13 -0
- avrotize/dependencies/rust/stable/Cargo.toml +17 -0
- avrotize/dependencies/typescript/node22/package.json +16 -0
- avrotize/dependency_resolver.py +348 -0
- avrotize/dependency_version.py +432 -0
- avrotize/generic/generic.avsc +57 -0
- avrotize/jsonstoavro.py +2167 -0
- avrotize/jsonstostructure.py +2864 -0
- avrotize/jstructtoavro.py +878 -0
- avrotize/kstructtoavro.py +93 -0
- avrotize/kustotoavro.py +455 -0
- avrotize/openapitostructure.py +717 -0
- avrotize/parquettoavro.py +157 -0
- avrotize/proto2parser.py +498 -0
- avrotize/proto3parser.py +403 -0
- avrotize/prototoavro.py +382 -0
- avrotize/prototypes/any.avsc +19 -0
- avrotize/prototypes/api.avsc +106 -0
- avrotize/prototypes/duration.avsc +20 -0
- avrotize/prototypes/field_mask.avsc +18 -0
- avrotize/prototypes/struct.avsc +60 -0
- avrotize/prototypes/timestamp.avsc +20 -0
- avrotize/prototypes/type.avsc +253 -0
- avrotize/prototypes/wrappers.avsc +117 -0
- avrotize/structuretocddl.py +597 -0
- avrotize/structuretocpp/CMakeLists.txt.jinja +76 -0
- avrotize/structuretocpp/build.bat.jinja +3 -0
- avrotize/structuretocpp/build.sh.jinja +3 -0
- avrotize/structuretocpp/dataclass_body.jinja +50 -0
- avrotize/structuretocpp/vcpkg.json.jinja +11 -0
- avrotize/structuretocpp.py +697 -0
- avrotize/structuretocsharp/class_test.cs.jinja +180 -0
- avrotize/structuretocsharp/dataclass_core.jinja +156 -0
- avrotize/structuretocsharp/enum_test.cs.jinja +36 -0
- avrotize/structuretocsharp/json_structure_converters.cs.jinja +399 -0
- avrotize/structuretocsharp/program.cs.jinja +49 -0
- avrotize/structuretocsharp/project.csproj.jinja +17 -0
- avrotize/structuretocsharp/project.sln.jinja +34 -0
- avrotize/structuretocsharp/testproject.csproj.jinja +18 -0
- avrotize/structuretocsharp/tuple_converter.cs.jinja +121 -0
- avrotize/structuretocsharp.py +2295 -0
- avrotize/structuretocsv.py +365 -0
- avrotize/structuretodatapackage.py +659 -0
- avrotize/structuretodb.py +1125 -0
- avrotize/structuretogo/go_enum.jinja +12 -0
- avrotize/structuretogo/go_helpers.jinja +26 -0
- avrotize/structuretogo/go_interface.jinja +18 -0
- avrotize/structuretogo/go_struct.jinja +187 -0
- avrotize/structuretogo/go_test.jinja +70 -0
- avrotize/structuretogo.py +729 -0
- avrotize/structuretographql.py +502 -0
- avrotize/structuretoiceberg.py +355 -0
- avrotize/structuretojava/choice_core.jinja +34 -0
- avrotize/structuretojava/class_core.jinja +23 -0
- avrotize/structuretojava/enum_core.jinja +18 -0
- avrotize/structuretojava/equals_hashcode.jinja +30 -0
- avrotize/structuretojava/pom.xml.jinja +26 -0
- avrotize/structuretojava/tuple_core.jinja +49 -0
- avrotize/structuretojava.py +938 -0
- avrotize/structuretojs/class_core.js.jinja +33 -0
- avrotize/structuretojs/enum_core.js.jinja +10 -0
- avrotize/structuretojs/package.json.jinja +12 -0
- avrotize/structuretojs/test_class.js.jinja +84 -0
- avrotize/structuretojs/test_enum.js.jinja +58 -0
- avrotize/structuretojs/test_runner.js.jinja +45 -0
- avrotize/structuretojs.py +657 -0
- avrotize/structuretojsons.py +498 -0
- avrotize/structuretokusto.py +639 -0
- avrotize/structuretomd/README.md.jinja +204 -0
- avrotize/structuretomd.py +322 -0
- avrotize/structuretoproto.py +764 -0
- avrotize/structuretopython/dataclass_core.jinja +363 -0
- avrotize/structuretopython/enum_core.jinja +45 -0
- avrotize/structuretopython/map_alias.jinja +21 -0
- avrotize/structuretopython/pyproject_toml.jinja +23 -0
- avrotize/structuretopython/test_class.jinja +103 -0
- avrotize/structuretopython/test_enum.jinja +34 -0
- avrotize/structuretopython.py +799 -0
- avrotize/structuretorust/dataclass_enum.rs.jinja +63 -0
- avrotize/structuretorust/dataclass_struct.rs.jinja +121 -0
- avrotize/structuretorust/dataclass_union.rs.jinja +81 -0
- avrotize/structuretorust.py +714 -0
- avrotize/structuretots/class_core.ts.jinja +78 -0
- avrotize/structuretots/enum_core.ts.jinja +6 -0
- avrotize/structuretots/gitignore.jinja +8 -0
- avrotize/structuretots/index.ts.jinja +1 -0
- avrotize/structuretots/package.json.jinja +39 -0
- avrotize/structuretots/test_class.ts.jinja +35 -0
- avrotize/structuretots/tsconfig.json.jinja +21 -0
- avrotize/structuretots.py +740 -0
- avrotize/structuretoxsd.py +679 -0
- avrotize/xsdtoavro.py +413 -0
- avrotize-2.21.1.dist-info/METADATA +1319 -0
- avrotize-2.21.1.dist-info/RECORD +171 -0
- avrotize-2.21.1.dist-info/WHEEL +4 -0
- avrotize-2.21.1.dist-info/entry_points.txt +3 -0
- avrotize-2.21.1.dist-info/licenses/LICENSE +201 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
{%- if serde_annotation %}
|
|
2
|
+
use serde::{self, Serialize, Deserialize};
|
|
3
|
+
{%- endif %}
|
|
4
|
+
|
|
5
|
+
{% if doc %}
|
|
6
|
+
/// {{ doc }}
|
|
7
|
+
{%- endif %}
|
|
8
|
+
#[derive(Debug{%- if serde_annotation %}, Serialize, Deserialize{%- endif %}, PartialEq, Clone, Default)]
|
|
9
|
+
{%- if serde_annotation %}
|
|
10
|
+
#[serde(rename_all = "snake_case")]
|
|
11
|
+
{%- endif %}
|
|
12
|
+
pub enum {{ enum_name }} {
|
|
13
|
+
#[default]
|
|
14
|
+
{%- for symbol in symbols %}
|
|
15
|
+
{%- if serde_annotation and symbol.name != symbol.value %}
|
|
16
|
+
#[serde(rename = "{{ symbol.value }}")]
|
|
17
|
+
{%- endif %}
|
|
18
|
+
{{ symbol.name }},
|
|
19
|
+
{%- endfor %}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
{%- if serde_annotation %}
|
|
23
|
+
impl {{ enum_name }} {
|
|
24
|
+
pub fn is_json_match(node: &serde_json::Value) -> bool {
|
|
25
|
+
return node.is_string();
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/// Returns the struct instance itself
|
|
29
|
+
pub fn to_object(&self) -> &Self {
|
|
30
|
+
return self;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
{%- endif %}
|
|
34
|
+
|
|
35
|
+
#[cfg(test)]
|
|
36
|
+
impl {{ enum_name }} {
|
|
37
|
+
pub fn generate_random_instance() -> {{ enum_name }} {
|
|
38
|
+
let mut rng = rand::thread_rng();
|
|
39
|
+
match rand::Rng::gen_range(&mut rng, 0..{{ symbols | length }}) {
|
|
40
|
+
{%- for symbol in symbols %}
|
|
41
|
+
{{ loop.index0 }} => {{ enum_name }}::{{ symbol.name }},
|
|
42
|
+
{%- endfor %}
|
|
43
|
+
_ => panic!("Invalid random index generated"),
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
#[cfg(test)]
|
|
49
|
+
mod tests {
|
|
50
|
+
use super::*;
|
|
51
|
+
use rand::Rng;
|
|
52
|
+
|
|
53
|
+
#[test]
|
|
54
|
+
fn test_enum_values_{{ enum_name.lower() }}() {
|
|
55
|
+
{%- for symbol in symbols %}
|
|
56
|
+
let instance = {{ enum_name }}::{{ symbol.name }};
|
|
57
|
+
{%- if serde_annotation %}
|
|
58
|
+
let json = serde_json::to_string(&instance).unwrap();
|
|
59
|
+
assert!(json.contains("{{ symbol.value }}"));
|
|
60
|
+
{%- endif %}
|
|
61
|
+
{%- endfor %}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
{%- if serde_annotation %}
|
|
2
|
+
use serde::{Serialize, Deserialize};
|
|
3
|
+
{%- endif %}
|
|
4
|
+
use std::io::Write;
|
|
5
|
+
use flate2::write::GzEncoder;
|
|
6
|
+
use flate2::read::GzDecoder;
|
|
7
|
+
|
|
8
|
+
{% if doc %}
|
|
9
|
+
/// {{ doc }}
|
|
10
|
+
{%- endif %}
|
|
11
|
+
#[derive(Debug{%- if serde_annotation %}, Serialize, Deserialize{%- endif %}, PartialEq, Clone, Default)]
|
|
12
|
+
pub struct {{ struct_name }} {
|
|
13
|
+
{%- for field in fields %}
|
|
14
|
+
{%- if field.serde_rename and serde_annotation %}
|
|
15
|
+
#[serde(rename = "{{ field.original_name }}")]
|
|
16
|
+
{%- endif %}
|
|
17
|
+
pub {{ field.name }}: {{ field.type }},
|
|
18
|
+
{%- endfor %}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
impl {{ struct_name }} {
|
|
22
|
+
/// Serializes the struct to a byte array based on the provided content type
|
|
23
|
+
pub fn to_byte_array(&self, content_type: &str) -> Result<Vec<u8>, Box<dyn std::error::Error>> {
|
|
24
|
+
let result: Vec<u8>;
|
|
25
|
+
let media_type = content_type.split(';').next().unwrap_or("");
|
|
26
|
+
{%- if serde_annotation %}
|
|
27
|
+
if media_type.starts_with("application/json") {
|
|
28
|
+
result = serde_json::to_vec(self)?;
|
|
29
|
+
}
|
|
30
|
+
else {% endif -%}
|
|
31
|
+
{
|
|
32
|
+
return Err(format!("unsupported media type: {}", media_type).into())
|
|
33
|
+
}
|
|
34
|
+
if media_type.ends_with("+gzip") {
|
|
35
|
+
let mut encoder = GzEncoder::new(Vec::new(), flate2::Compression::default());
|
|
36
|
+
encoder.write_all(&result)?;
|
|
37
|
+
let gzipresult = encoder.finish()?;
|
|
38
|
+
return Ok(gzipresult)
|
|
39
|
+
} else {
|
|
40
|
+
return Ok(result)
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/// Deserializes the struct from a byte array based on the provided content type
|
|
45
|
+
pub fn from_data(data: impl AsRef<[u8]>, content_type: &str) -> Result<Self, Box<dyn std::error::Error>> {
|
|
46
|
+
let media_type = content_type.split(';').next().unwrap_or("");
|
|
47
|
+
let data = if media_type.ends_with("+gzip") {
|
|
48
|
+
let mut decoder = GzDecoder::new(data.as_ref());
|
|
49
|
+
let mut decompressed_data = Vec::new();
|
|
50
|
+
std::io::copy(&mut decoder, &mut decompressed_data)?;
|
|
51
|
+
decompressed_data
|
|
52
|
+
} else {
|
|
53
|
+
data.as_ref().to_vec()
|
|
54
|
+
};
|
|
55
|
+
{%- if serde_annotation %}
|
|
56
|
+
if media_type.starts_with("application/json") {
|
|
57
|
+
let result = serde_json::from_slice(&data)?;
|
|
58
|
+
return Ok(result)
|
|
59
|
+
}
|
|
60
|
+
{%- endif %}
|
|
61
|
+
Err(format!("unsupported media type: {}", media_type).into())
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/// Returns the struct instance itself
|
|
65
|
+
pub fn to_object(&self) -> &Self {
|
|
66
|
+
self
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
#[cfg(test)]
|
|
71
|
+
impl {{ struct_name }} {
|
|
72
|
+
pub fn generate_random_instance() -> {{ struct_name }} {
|
|
73
|
+
let mut rng = rand::thread_rng();
|
|
74
|
+
{{ struct_name }} {
|
|
75
|
+
{%- for field in fields %}
|
|
76
|
+
{%- if field.type.startswith("Option<") %}
|
|
77
|
+
{{ field.name }}: Some({{ field.random_value }}),
|
|
78
|
+
{%- else %}
|
|
79
|
+
{{ field.name }}: {{ field.random_value }},
|
|
80
|
+
{%- endif %}
|
|
81
|
+
{%- endfor %}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
#[cfg(test)]
|
|
87
|
+
mod tests {
|
|
88
|
+
use super::*;
|
|
89
|
+
|
|
90
|
+
#[test]
|
|
91
|
+
fn test_create_{{ struct_name.lower() }}() {
|
|
92
|
+
let instance = {{struct_name}}::generate_random_instance();
|
|
93
|
+
{%- for field in fields %}
|
|
94
|
+
{%- if field.type.startswith("Option<") %}
|
|
95
|
+
assert!(instance.{{ field.name }}.is_some()); // Check that {{ field.name }} is not None
|
|
96
|
+
{%- elif field.type.startswith("Vec<") %}
|
|
97
|
+
{%- set field_type = 'Vec::<'+field.type[4:] %}
|
|
98
|
+
assert!(instance.{{ field.name }} != {{ field_type }}::default()); // Check that {{ field.name }} is not default
|
|
99
|
+
{%- elif field.type.startswith("std::collections::HashMap<")%}
|
|
100
|
+
assert!(instance.{{ field.name }}.len() >= 0); // Check that {{ field.name }} is not empty
|
|
101
|
+
{%- elif field.type != "bool" %}
|
|
102
|
+
assert!(instance.{{ field.name }} != {{ field.type }}::default()); // Check that {{ field.name }} is not default
|
|
103
|
+
{%- endif %}
|
|
104
|
+
{%- endfor %}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
{%- if serde_annotation %}
|
|
108
|
+
#[test]
|
|
109
|
+
fn test_serialize_deserialize_{{ struct_name.lower() }}() {
|
|
110
|
+
let instance = {{struct_name}}::generate_random_instance();
|
|
111
|
+
// Test JSON serialization and deserialization
|
|
112
|
+
let json_bytes = instance.to_byte_array("application/json").unwrap();
|
|
113
|
+
let deserialized_instance: {{ struct_name }} = {{ struct_name }}::from_data(&json_bytes, "application/json").unwrap();
|
|
114
|
+
assert_eq!(instance, deserialized_instance);
|
|
115
|
+
// Test JSON serialization and deserialization with compression
|
|
116
|
+
let json_gzip_bytes = instance.to_byte_array("application/json+gzip").unwrap();
|
|
117
|
+
let deserialized_gzip_instance: {{ struct_name }} = {{ struct_name }}::from_data(&json_gzip_bytes, "application/json+gzip").unwrap();
|
|
118
|
+
assert_eq!(instance, deserialized_gzip_instance);
|
|
119
|
+
}
|
|
120
|
+
{%- endif %}
|
|
121
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
{%- if serde_annotation %}
|
|
2
|
+
use serde::{self, Serialize, Deserialize};
|
|
3
|
+
{%- endif %}
|
|
4
|
+
|
|
5
|
+
{% if doc %}
|
|
6
|
+
/// {{ doc }}
|
|
7
|
+
{%- endif %}
|
|
8
|
+
#[derive(Debug, PartialEq, Clone)]
|
|
9
|
+
{%- if serde_annotation %}
|
|
10
|
+
#[serde(untagged)]
|
|
11
|
+
{%- endif %}
|
|
12
|
+
pub enum {{ union_enum_name }} {
|
|
13
|
+
{%- for variant in variants %}
|
|
14
|
+
{{ variant.variant_name }}({{ variant.type -}})
|
|
15
|
+
{%- if not loop.last %},{% endif %}
|
|
16
|
+
{%- endfor %}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
impl Default for {{ union_enum_name }} {
|
|
20
|
+
fn default() -> Self {
|
|
21
|
+
return {{ union_enum_name }}::{{ variants[0].variant_name }}(Default::default())
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
{%- if serde_annotation %}
|
|
26
|
+
impl Serialize for {{ union_enum_name }} {
|
|
27
|
+
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
|
28
|
+
where
|
|
29
|
+
S: serde::ser::Serializer
|
|
30
|
+
{
|
|
31
|
+
match self {
|
|
32
|
+
{%- for variant in variants %}
|
|
33
|
+
{{ union_enum_name }}::{{ variant.variant_name}}(value) => value.serialize(serializer),
|
|
34
|
+
{%- endfor %}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
impl<'de> Deserialize<'de> for {{ union_enum_name }} {
|
|
40
|
+
fn deserialize<D>(deserializer: D) -> Result<{{ union_enum_name }}, D::Error>
|
|
41
|
+
where
|
|
42
|
+
D: serde::de::Deserializer<'de>
|
|
43
|
+
{
|
|
44
|
+
let node = serde_json::Value::deserialize(deserializer)?;
|
|
45
|
+
{%- for variant in variants %}
|
|
46
|
+
{
|
|
47
|
+
if let Ok(value) = serde_json::from_value::<{{ variant.type }}>(node.clone()) {
|
|
48
|
+
return Ok({{ union_enum_name }}::{{ variant.variant_name }}(value));
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
{%- endfor %}
|
|
52
|
+
Err(serde::de::Error::custom("No valid variant found"))
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
{%- endif %}
|
|
56
|
+
|
|
57
|
+
#[cfg(test)]
|
|
58
|
+
impl {{ union_enum_name }} {
|
|
59
|
+
pub fn generate_random_instance() -> {{ union_enum_name }} {
|
|
60
|
+
let mut rng = rand::thread_rng();
|
|
61
|
+
match rand::Rng::gen_range(&mut rng, 0..{{ variants | length }}) {
|
|
62
|
+
{%- for variant in variants %}
|
|
63
|
+
{{ loop.index0 }} => {{ union_enum_name }}::{{ variant.variant_name }}(Default::default()),
|
|
64
|
+
{%- endfor %}
|
|
65
|
+
_ => panic!("Invalid random index generated"),
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
#[cfg(test)]
|
|
71
|
+
mod tests {
|
|
72
|
+
use super::*;
|
|
73
|
+
|
|
74
|
+
#[test]
|
|
75
|
+
fn test_union_variants_{{ union_enum_name.lower() }}() {
|
|
76
|
+
{%- for variant in variants %}
|
|
77
|
+
let instance = {{ union_enum_name }}::{{ variant.variant_name }}(Default::default());
|
|
78
|
+
assert!(matches!(instance, {{ union_enum_name }}::{{ variant.variant_name }}(_)));
|
|
79
|
+
{%- endfor %}
|
|
80
|
+
}
|
|
81
|
+
}
|