// Copyright 2022 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// LINT: ALLOW_GROUPS

syntax = "proto2";

package fuzztest.internal;

enum BareEnum {
  LABEL_DEFAULT = 0;
  LABEL_OTHER = 10;
}

message TestSubProtobuf {
  optional int32 subproto_i32 = 1;
  repeated int32 subproto_rep_i32 = 2 [packed = true];
}

message TestProtobuf {
  enum Enum {
    Label1 = 0;
    Label2 = 1;
    Label3 = 2;
    Label4 = 3;
    Label5 = 4;
  }

  optional bool b = 1;
  optional int32 i32 = 2;
  optional uint32 u32 = 3;
  optional int64 i64 = 4;
  optional uint64 u64 = 5;
  optional float f = 6;
  optional double d = 7;
  optional string str = 8;
  optional Enum e = 9;
  optional TestSubProtobuf subproto = 10;

  repeated bool rep_b = 11;
  repeated int32 rep_i32 = 12;
  repeated uint32 rep_u32 = 13;
  repeated int64 rep_i64 = 14;
  repeated uint64 rep_u64 = 15;
  repeated float rep_f = 16;
  repeated double rep_d = 17;
  repeated string rep_str = 18;
  repeated Enum rep_e = 19;
  repeated TestSubProtobuf rep_subproto = 20;

  oneof oneof_field {
    int32 oneof_i32 = 21;
    int64 oneof_i64 = 22;
    uint32 oneof_u32 = 24;
  }

  map<int32, int32> map_field = 25;

  // Special cases
  enum EnumOneLabel {
    OnlyLabel = 17;
  }
  optional EnumOneLabel enum_one_label = 100;
  message EmptyMessage {}
  optional EmptyMessage empty_message = 101;
}

message TestProtobufWithRequired {
  optional int32 i32 = 1;

  required int32 req_i32 = 200;
  required TestProtobuf.Enum req_e = 201;
  required TestSubProtobuf req_sub = 202;
  optional TestProtobufWithRequired sub_req = 203;
  map<int32, TestProtobufWithRequired> map_sub_req = 204;
}

message IRObjectTestProto {
  oneof value {
    uint64 i = 1;
    double d = 2;
    bytes s = 3;
  }
  repeated IRObjectTestProto sub = 4;
}

message TestProtobufWithExtension {
  optional int32 non_ext = 1;
  extensions 1000 to max;
}

message ProtoExtender {
  extend TestProtobufWithExtension {
    optional string ext = 1001;
    repeated string rep_ext = 1002;
  }
}

message RecursiveExtender {
  extend TestProtobufWithExtension {
    optional TestProtobufWithRecursion parent = 2001;
  }
}

message TestProtobufWithRecursion {
  message ChildProto {
    optional TestProtobufWithRecursion parent1 = 1;
    optional TestProtobufWithRecursion parent2 = 2;
    optional TestProtobufWithRecursion parent3 = 3;
    optional string id = 4;
  }
  optional int32 id = 1;
  oneof type {
    ChildProto child = 2;
    int32 child_id = 3;
  }
  optional TestProtobufWithExtension ext = 4;
}

message MessageWithGroup {
  optional group GroupField = 1 {
    optional int64 field1 = 2;
    optional int64 field2 = 3;
  }
}
