diff options
author | Wink Saville <wink@google.com> | 2013-08-07 19:57:30 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2013-08-07 19:57:30 +0000 |
commit | 062d561e31212186740a94a9861a52658267c8d2 (patch) | |
tree | f5d666cff2a7158647600a3dea08d42f8139aa03 /java/src | |
parent | cebd784d19369de465ec21b9f1a38ffa14a06196 (diff) | |
parent | 06eed37ec6a0bc912c0f342ee92449069846cea1 (diff) | |
download | protobuf-062d561e31212186740a94a9861a52658267c8d2.tar.gz protobuf-062d561e31212186740a94a9861a52658267c8d2.tar.bz2 protobuf-062d561e31212186740a94a9861a52658267c8d2.zip |
Merge "Fix outer classname for javamicro/javanano."
Diffstat (limited to 'java/src')
-rw-r--r-- | java/src/test/java/com/google/protobuf/NanoTest.java | 45 |
1 files changed, 43 insertions, 2 deletions
diff --git a/java/src/test/java/com/google/protobuf/NanoTest.java b/java/src/test/java/com/google/protobuf/NanoTest.java index 23768b78..b00f2892 100644 --- a/java/src/test/java/com/google/protobuf/NanoTest.java +++ b/java/src/test/java/com/google/protobuf/NanoTest.java @@ -33,16 +33,22 @@ package com.google.protobuf; import com.google.protobuf.nano.CodedInputByteBufferNano; import com.google.protobuf.nano.Extensions; import com.google.protobuf.nano.Extensions.AnotherMessage; +import com.google.protobuf.nano.FileScopeEnumRefNano; import com.google.protobuf.nano.InternalNano; import com.google.protobuf.nano.MessageNano; +import com.google.protobuf.nano.MessageScopeEnumRefNano; import com.google.protobuf.nano.MultipleImportingNonMultipleNano1; import com.google.protobuf.nano.MultipleImportingNonMultipleNano2; +import com.google.protobuf.nano.MultipleNameClashNano; import com.google.protobuf.nano.NanoHasOuterClass.TestAllTypesNanoHas; import com.google.protobuf.nano.NanoOuterClass; import com.google.protobuf.nano.NanoOuterClass.TestAllTypesNano; -import com.google.protobuf.nano.RecursiveMessageNano; -import com.google.protobuf.nano.SimpleMessageNano; import com.google.protobuf.nano.UnittestImportNano; +import com.google.protobuf.nano.UnittestMultipleNano; +import com.google.protobuf.nano.UnittestRecursiveNano.RecursiveMessageNano; +import com.google.protobuf.nano.UnittestSimpleNano.SimpleMessageNano; +import com.google.protobuf.nano.UnittestSingleNano.SingleMessageNano; +import com.google.protobuf.nano.UnittestStringutf8Nano.StringUtf8; import junit.framework.TestCase; @@ -2062,6 +2068,41 @@ public class NanoTest extends TestCase { } /** + * Tests that code generation correctly wraps a single message into its outer + * class. The class {@code SingleMessageNano} is imported from the outer + * class {@code UnittestSingleNano}, whose name is implicit. Any error would + * cause this method to fail compilation. + */ + public void testNanoSingle() throws Exception { + SingleMessageNano msg = new SingleMessageNano(); + } + + /** + * Tests that code generation correctly skips generating the outer class if + * unnecessary, letting a file-scope entity have the same name. The class + * {@code MultipleNameClashNano} shares the same name with the file's outer + * class defined explicitly, but the file contains no other entities and has + * java_multiple_files set. Any error would cause this method to fail + * compilation. + */ + public void testNanoMultipleNameClash() throws Exception { + MultipleNameClashNano msg = new MultipleNameClashNano(); + msg.field = 0; + } + + /** + * Tests that code generation correctly handles enums in different scopes in + * a source file with the option java_multiple_files set to true. Any error + * would cause this method to fail compilation. + */ + public void testNanoMultipleEnumScoping() throws Exception { + FileScopeEnumRefNano msg1 = new FileScopeEnumRefNano(); + msg1.enumField = UnittestMultipleNano.ONE; + MessageScopeEnumRefNano msg2 = new MessageScopeEnumRefNano(); + msg2.enumField = MessageScopeEnumRefNano.TWO; + } + + /** * Tests that code generation with mixed values of the java_multiple_files * options between the main source file and the imported source files would * generate correct references. Any error would cause this method to fail |