Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1356,6 +1356,16 @@ private static void generateEnum(final List<Token> enumTokens, final OutputManag
.append(",\n");
}

// null value
final Token token = messageBody.get(0);
final Encoding encoding = token.encoding();
final CharSequence nullVal = generateRustLiteral(
encoding.primitiveType(), encoding.applicableNullValue().toString());
indent(writer, 1).append("NullVal")
.append(" = ")
.append(nullVal)
.append(",\n");

writer.append("}\n");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ private void assertContainsNumericEnum(final String generatedRust)
"pub enum ENUM {\n" +
" Value1 = 1u8,\n" +
" Value10 = 10u8,\n" +
" NullVal = 255u8,\n" +
"}\n";
assertTrue(generatedRust.contains(expectedDeclaration));
}
Expand All @@ -144,6 +145,7 @@ public void fullGenerateBroadUseCase() throws IOException, InterruptedException
"pub enum BooleanType {\n" +
" F = 0u8,\n" +
" T = 1u8,\n" +
" NullVal = 255u8,\n" +
"}\n";
assertTrue(generatedRust.contains(expectedBooleanTypeDeclaration));
final String expectedCharTypeDeclaration =
Expand All @@ -153,6 +155,7 @@ public void fullGenerateBroadUseCase() throws IOException, InterruptedException
" A = 65i8,\n" +
" B = 66i8,\n" +
" C = 67i8,\n" +
" NullVal = 0i8,\n" +
"}\n";
assertTrue(generatedRust.contains(expectedCharTypeDeclaration));
assertRustBuildable(generatedRust, Optional.of("example-schema"));
Expand Down Expand Up @@ -283,6 +286,7 @@ public void constantEnumFields() throws IOException, InterruptedException
" A = 65i8,\n" +
" B = 66i8,\n" +
" C = 67i8,\n" +
" NullVal = 0i8,\n" +
"}\n";
assertContains(rust, expectedCharTypeDeclaration);
assertContains(rust, "pub struct ConstantEnumsFields {\n}");
Expand Down Expand Up @@ -313,6 +317,7 @@ public void constantFieldsCase() throws IOException, InterruptedException
" A = 65i8,\n" +
" B = 66i8,\n" +
" C = 67i8,\n" +
" NullVal = 0i8,\n" +
"}\n";
assertContains(rust, expectedCharTypeDeclaration);
final String expectedComposite =
Expand Down