### Question:
UUnary extends UExpression implements UnaryTree { public static UUnary create(Kind unaryOp, UExpression expression) { checkArgument( UNARY_OP_CODES.containsKey(unaryOp), "%s is not a recognized unary operation", unaryOp); return new AutoValue_UUnary(unaryOp, expression); }  static UUnary create(Kind unaryOp, UExpression expression); @Override abstract Kind getKind(); @Override abstract UExpression getExpression(); @Override @Nullable Choice<Unifier> visitUnary(UnaryTree unary, @Nullable Unifier unifier); @Override R accept(TreeVisitor<R, D> visitor, D data); @Override JCExpression inline(Inliner inliner); @Override UExpression negate();  }### Answer:
@Test public void rejectsNonUnaryOperations() { ULiteral sevenLit = ULiteral.intLit(7); assertThrows(IllegalArgumentException.class, () -> UUnary.create(Kind.PLUS, sevenLit)); }
@Test public void complement() { assertUnifiesAndInlines("~7", UUnary.create(Kind.BITWISE_COMPLEMENT, ULiteral.intLit(7))); }
@Test public void logicalNegation() { assertUnifiesAndInlines( "!false", UUnary.create(Kind.LOGICAL_COMPLEMENT, ULiteral.booleanLit(false))); }
@Test public void unaryPlus() { assertUnifiesAndInlines("+foo", UUnary.create(Kind.UNARY_PLUS, fooIdent)); }
@Test public void unaryNegation() { assertUnifiesAndInlines("-foo", UUnary.create(Kind.UNARY_MINUS, fooIdent)); }
@Test public void preIncrement() { assertUnifiesAndInlines("++foo", UUnary.create(Kind.PREFIX_INCREMENT, fooIdent)); }
@Test public void postIncrement() { assertUnifiesAndInlines("foo++", UUnary.create(Kind.POSTFIX_INCREMENT, fooIdent)); }
@Test public void preDecrement() { assertUnifiesAndInlines("--foo", UUnary.create(Kind.PREFIX_DECREMENT, fooIdent)); }
@Test public void postDecrement() { assertUnifiesAndInlines("foo--", UUnary.create(Kind.POSTFIX_DECREMENT, fooIdent)); }
@Test public void equality() { ULiteral sevenLit = ULiteral.intLit(7); ULiteral threeLit = ULiteral.intLit(3); ULiteral falseLit = ULiteral.booleanLit(false); new EqualsTester() .addEqualityGroup(UUnary.create(Kind.UNARY_MINUS, sevenLit)) .addEqualityGroup(UUnary.create(Kind.UNARY_MINUS, threeLit)) .addEqualityGroup(UUnary.create(Kind.BITWISE_COMPLEMENT, sevenLit)) .addEqualityGroup(UUnary.create(Kind.LOGICAL_COMPLEMENT, falseLit)) .testEquals(); }
@Test public void serialization() { SerializableTester.reserializeAndAssert( UUnary.create(Kind.BITWISE_COMPLEMENT, ULiteral.intLit(7))); }