mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
Clean up Java style (#5990)
Also make equivalent changes in C++ where applicable. Co-authored-by: Sriman Achanta <68172138+srimanachanta@users.noreply.github.com>
This commit is contained in:
@@ -15,21 +15,21 @@ class ParserTest {
|
||||
@Test
|
||||
void testEmpty() {
|
||||
Parser p = new Parser("");
|
||||
ParsedSchema schema = assertDoesNotThrow(() -> p.parse());
|
||||
ParsedSchema schema = assertDoesNotThrow(p::parse);
|
||||
assertTrue(schema.declarations.isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testEmptySemicolon() {
|
||||
Parser p = new Parser(";");
|
||||
ParsedSchema schema = assertDoesNotThrow(() -> p.parse());
|
||||
ParsedSchema schema = assertDoesNotThrow(p::parse);
|
||||
assertTrue(schema.declarations.isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSimple() {
|
||||
Parser p = new Parser("int32 a");
|
||||
ParsedSchema schema = assertDoesNotThrow(() -> p.parse());
|
||||
ParsedSchema schema = assertDoesNotThrow(p::parse);
|
||||
assertEquals(schema.declarations.size(), 1);
|
||||
var decl = schema.declarations.get(0);
|
||||
assertEquals(decl.typeString, "int32");
|
||||
@@ -40,14 +40,14 @@ class ParserTest {
|
||||
@Test
|
||||
void testSimpleTrailingSemi() {
|
||||
Parser p = new Parser("int32 a;");
|
||||
ParsedSchema schema = assertDoesNotThrow(() -> p.parse());
|
||||
ParsedSchema schema = assertDoesNotThrow(p::parse);
|
||||
assertEquals(schema.declarations.size(), 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testArray() {
|
||||
Parser p = new Parser("int32 a[2]");
|
||||
ParsedSchema schema = assertDoesNotThrow(() -> p.parse());
|
||||
ParsedSchema schema = assertDoesNotThrow(p::parse);
|
||||
assertEquals(schema.declarations.size(), 1);
|
||||
var decl = schema.declarations.get(0);
|
||||
assertEquals(decl.typeString, "int32");
|
||||
@@ -58,14 +58,14 @@ class ParserTest {
|
||||
@Test
|
||||
void testArrayTrailingSemi() {
|
||||
Parser p = new Parser("int32 a[2];");
|
||||
ParsedSchema schema = assertDoesNotThrow(() -> p.parse());
|
||||
ParsedSchema schema = assertDoesNotThrow(p::parse);
|
||||
assertEquals(schema.declarations.size(), 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBitfield() {
|
||||
Parser p = new Parser("int32 a:2");
|
||||
ParsedSchema schema = assertDoesNotThrow(() -> p.parse());
|
||||
ParsedSchema schema = assertDoesNotThrow(p::parse);
|
||||
assertEquals(schema.declarations.size(), 1);
|
||||
var decl = schema.declarations.get(0);
|
||||
assertEquals(decl.typeString, "int32");
|
||||
@@ -76,14 +76,14 @@ class ParserTest {
|
||||
@Test
|
||||
void testBitfieldTrailingSemi() {
|
||||
Parser p = new Parser("int32 a:2;");
|
||||
ParsedSchema schema = assertDoesNotThrow(() -> p.parse());
|
||||
ParsedSchema schema = assertDoesNotThrow(p::parse);
|
||||
assertEquals(schema.declarations.size(), 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testEnumKeyword() {
|
||||
Parser p = new Parser("enum {x=1} int32 a;");
|
||||
ParsedSchema schema = assertDoesNotThrow(() -> p.parse());
|
||||
ParsedSchema schema = assertDoesNotThrow(p::parse);
|
||||
assertEquals(schema.declarations.size(), 1);
|
||||
var decl = schema.declarations.get(0);
|
||||
assertEquals(decl.typeString, "int32");
|
||||
@@ -95,7 +95,7 @@ class ParserTest {
|
||||
@Test
|
||||
void testEnumNoKeyword() {
|
||||
Parser p = new Parser("{x=1} int32 a;");
|
||||
ParsedSchema schema = assertDoesNotThrow(() -> p.parse());
|
||||
ParsedSchema schema = assertDoesNotThrow(p::parse);
|
||||
assertEquals(schema.declarations.size(), 1);
|
||||
var decl = schema.declarations.get(0);
|
||||
assertEquals(decl.typeString, "int32");
|
||||
@@ -107,7 +107,7 @@ class ParserTest {
|
||||
@Test
|
||||
void testEnumNoValues() {
|
||||
Parser p = new Parser("{} int32 a;");
|
||||
ParsedSchema schema = assertDoesNotThrow(() -> p.parse());
|
||||
ParsedSchema schema = assertDoesNotThrow(p::parse);
|
||||
assertEquals(schema.declarations.size(), 1);
|
||||
var decl = schema.declarations.get(0);
|
||||
assertEquals(decl.typeString, "int32");
|
||||
@@ -118,7 +118,7 @@ class ParserTest {
|
||||
@Test
|
||||
void testEnumMultipleValues() {
|
||||
Parser p = new Parser("{x=1,y=-2} int32 a;");
|
||||
ParsedSchema schema = assertDoesNotThrow(() -> p.parse());
|
||||
ParsedSchema schema = assertDoesNotThrow(p::parse);
|
||||
assertEquals(schema.declarations.size(), 1);
|
||||
var decl = schema.declarations.get(0);
|
||||
assertEquals(decl.typeString, "int32");
|
||||
@@ -131,7 +131,7 @@ class ParserTest {
|
||||
@Test
|
||||
void testEnumTrailingComma() {
|
||||
Parser p = new Parser("{x=1,y=2,} int32 a;");
|
||||
ParsedSchema schema = assertDoesNotThrow(() -> p.parse());
|
||||
ParsedSchema schema = assertDoesNotThrow(p::parse);
|
||||
assertEquals(schema.declarations.size(), 1);
|
||||
var decl = schema.declarations.get(0);
|
||||
assertEquals(decl.typeString, "int32");
|
||||
@@ -144,7 +144,7 @@ class ParserTest {
|
||||
@Test
|
||||
void testMultipleNoTrailingSemi() {
|
||||
Parser p = new Parser("int32 a; int16 b");
|
||||
ParsedSchema schema = assertDoesNotThrow(() -> p.parse());
|
||||
ParsedSchema schema = assertDoesNotThrow(p::parse);
|
||||
assertEquals(schema.declarations.size(), 2);
|
||||
assertEquals(schema.declarations.get(0).typeString, "int32");
|
||||
assertEquals(schema.declarations.get(0).name, "a");
|
||||
@@ -155,58 +155,55 @@ class ParserTest {
|
||||
@Test
|
||||
void testErrBitfieldArray() {
|
||||
Parser p = new Parser("int32 a[1]:2");
|
||||
assertThrows(ParseException.class, () -> p.parse(), "10: expected ';', got ':'");
|
||||
assertThrows(ParseException.class, p::parse, "10: expected ';', got ':'");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testErrNoArrayValue() {
|
||||
Parser p = new Parser("int32 a[]");
|
||||
assertThrows(ParseException.class, () -> p.parse(), "8: expected integer, got ']'");
|
||||
assertThrows(ParseException.class, p::parse, "8: expected integer, got ']'");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testErrNoBitfieldValue() {
|
||||
Parser p = new Parser("int32 a:");
|
||||
assertThrows(ParseException.class, () -> p.parse(), "8: expected integer, got ''");
|
||||
assertThrows(ParseException.class, p::parse, "8: expected integer, got ''");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testErrNoNameArray() {
|
||||
Parser p = new Parser("int32 [2]");
|
||||
assertThrows(ParseException.class, () -> p.parse(), "6: expected identifier, got '['");
|
||||
assertThrows(ParseException.class, p::parse, "6: expected identifier, got '['");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testErrNoNameBitField() {
|
||||
Parser p = new Parser("int32 :2");
|
||||
assertThrows(ParseException.class, () -> p.parse(), "6: expected identifier, got ':'");
|
||||
assertThrows(ParseException.class, p::parse, "6: expected identifier, got ':'");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testNegativeBitField() {
|
||||
Parser p = new Parser("int32 a:-1");
|
||||
assertThrows(
|
||||
ParseException.class, () -> p.parse(), "8: bitfield width '-1' is not a positive integer");
|
||||
ParseException.class, p::parse, "8: bitfield width '-1' is not a positive integer");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testNegativeArraySize() {
|
||||
Parser p = new Parser("int32 a[-1]");
|
||||
assertThrows(
|
||||
ParseException.class, () -> p.parse(), "8: array size '-1' is not a positive integer");
|
||||
assertThrows(ParseException.class, p::parse, "8: array size '-1' is not a positive integer");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testZeroBitField() {
|
||||
Parser p = new Parser("int32 a:0");
|
||||
assertThrows(
|
||||
ParseException.class, () -> p.parse(), "8: bitfield width '0' is not a positive integer");
|
||||
assertThrows(ParseException.class, p::parse, "8: bitfield width '0' is not a positive integer");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testZeroArraySize() {
|
||||
Parser p = new Parser("int32 a[0]");
|
||||
assertThrows(
|
||||
ParseException.class, () -> p.parse(), "8: array size '0' is not a positive integer");
|
||||
assertThrows(ParseException.class, p::parse, "8: array size '0' is not a positive integer");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user