blob: fe1a5354d55fadef32405cc4d45499d9856228ce [file] [log] [blame]
Stephan Herhut3f026d32017-08-07 14:58:13 +02001// Copyright (c) 2017, the R8 project authors. Please see the AUTHORS file
2// for details. All rights reserved. Use of this source code is governed by a
3// BSD-style license that can be found in the LICENSE file.
4package nestedproto1;
5
6import java.io.ByteArrayInputStream;
7import java.io.IOException;
8import nestedproto1.GeneratedNestedProto.Outer;
9
10public class Nestedproto {
11
12 private static final byte[] NESTED_MESSAGE_WITH_BOTH = new byte[] {25, 8, 42, 18, 12, 8, 1, 18, 8,
13 105, 110, 110, 101, 114, 79, 110, 101, 26, 7, 8, 2, 21, 0, 0, -10, 66};
14
15 private static final byte[] NESTED_MESSAGE_WITH_ONE = new byte[]{16, 8, 42, 18, 12, 8, 1, 18, 8,
16 105,
17 110, 110, 101, 114, 79, 110, 101};
18
19 public static void main(String... args) throws IOException {
20 testWith(NESTED_MESSAGE_WITH_BOTH);
21 testWith(NESTED_MESSAGE_WITH_ONE);
22 }
23
24 public static void testWith(byte[] data) throws IOException {
25 ByteArrayInputStream input = new ByteArrayInputStream(data);
26 Outer.Builder builder = Outer.newBuilder();
27 builder.mergeDelimitedFrom(input);
28 Outer outer = builder.build();
29 System.out.println(outer.getInner().getOther());
30 }
31}