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 | e7b778b99f607460ed9ea88a13ec91164cda8537 (patch) | |
tree | f7d79f8de4666a66a09928fbc3468516b1c4ec76 /java/src | |
parent | 87c8e31b8c0baa78f979863a9ed10654a1cdca1f (diff) | |
parent | 624c448fbef20a1a2fad2289f622b468c25763d1 (diff) | |
download | external_protobuf-e7b778b99f607460ed9ea88a13ec91164cda8537.zip external_protobuf-e7b778b99f607460ed9ea88a13ec91164cda8537.tar.gz external_protobuf-e7b778b99f607460ed9ea88a13ec91164cda8537.tar.bz2 |
Merge "Fix outer classname for javamicro/javanano."
Diffstat (limited to 'java/src')
-rw-r--r-- | java/src/test/java/com/google/protobuf/MicroTest.java | 46 | ||||
-rw-r--r-- | java/src/test/java/com/google/protobuf/NanoTest.java | 45 |
2 files changed, 86 insertions, 5 deletions
diff --git a/java/src/test/java/com/google/protobuf/MicroTest.java b/java/src/test/java/com/google/protobuf/MicroTest.java index 03005a7..1e43f07 100644 --- a/java/src/test/java/com/google/protobuf/MicroTest.java +++ b/java/src/test/java/com/google/protobuf/MicroTest.java @@ -32,14 +32,19 @@ package com.google.protobuf; import com.google.protobuf.micro.ByteStringMicro; import com.google.protobuf.micro.CodedInputStreamMicro; +import com.google.protobuf.micro.FileScopeEnumRefMicro; +import com.google.protobuf.micro.MessageScopeEnumRefMicro; import com.google.protobuf.micro.MicroOuterClass; import com.google.protobuf.micro.MicroOuterClass.TestAllTypesMicro; import com.google.protobuf.micro.MultipleImportingNonMultipleMicro1; import com.google.protobuf.micro.MultipleImportingNonMultipleMicro2; -import com.google.protobuf.micro.RecursiveMessageMicro; -import com.google.protobuf.micro.SimpleMessageMicro; -import com.google.protobuf.micro.StringUtf8; +import com.google.protobuf.micro.MultipleNameClashMicro; import com.google.protobuf.micro.UnittestImportMicro; +import com.google.protobuf.micro.UnittestMultipleMicro; +import com.google.protobuf.micro.UnittestRecursiveMicro.RecursiveMessageMicro; +import com.google.protobuf.micro.UnittestSimpleMicro.SimpleMessageMicro; +import com.google.protobuf.micro.UnittestSingleMicro.SingleMessageMicro; +import com.google.protobuf.micro.UnittestStringutf8Micro.StringUtf8; import junit.framework.TestCase; @@ -2104,6 +2109,41 @@ public class MicroTest extends TestCase { } /** + * Tests that code generation correctly wraps a single message into its outer + * class. The class {@code SingleMessageMicro} is imported from the outer + * class {@code UnittestSingleMicro}, whose name is implicit. Any error would + * cause this method to fail compilation. + */ + public void testMicroSingle() throws Exception { + SingleMessageMicro msg = new SingleMessageMicro(); + } + + /** + * Tests that code generation correctly skips generating the outer class if + * unnecessary, letting a file-scope entity have the same name. The class + * {@code MultipleNameClashMicro} 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 testMicroMultipleNameClash() throws Exception { + MultipleNameClashMicro msg = new MultipleNameClashMicro(); + msg.setField(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 testMicroMultipleEnumScoping() throws Exception { + FileScopeEnumRefMicro msg1 = new FileScopeEnumRefMicro(); + msg1.setEnumField(UnittestMultipleMicro.ONE); + MessageScopeEnumRefMicro msg2 = new MessageScopeEnumRefMicro(); + msg2.setEnumField(MessageScopeEnumRefMicro.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 diff --git a/java/src/test/java/com/google/protobuf/NanoTest.java b/java/src/test/java/com/google/protobuf/NanoTest.java index 23768b7..b00f289 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 |