• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Protocol Buffers - Google's data interchange format
2// Copyright 2023 Google LLC.  All rights reserved.
3//
4// Use of this source code is governed by a BSD-style
5// license that can be found in the LICENSE file or at
6// https://developers.google.com/open-source/licenses/bsd
7// LINT: LEGACY_NAMES
8
9// The names in this file are meant to test edge cases.
10syntax = "proto3";
11
12package enums;
13
14// This should result in an enum with these accessible values:
15// - Unknown = 0
16// - Unrecognized = 0
17// - Foo = 1
18// - Bar = 2
19// - DifferentNameAlias = 2
20enum TestEnumWithDuplicateStrippedPrefixNames {
21  option allow_alias = true;
22
23  UNKNOWN = 0;
24  TestEnumWithDuplicateStrippedPrefixNamesUNRECOGNIZED = 0;
25
26  TestEnumWithDuplicateStrippedPrefixNames_FOO = 1;
27  TEST_ENUM_WITH_DUPLICATE_STRIPPED_PREFIX_NAMES_FOO = 1;
28  FOO = 1;
29
30  TestEnumWithDuplicateStrippedPrefixNamesBAR = 2;
31  TEST_ENUM_WITH_DUPLICATE_STRIPPED_PREFIX_NAMESBar = 2;
32  BAR = 2;
33  TEST_ENUM_WITH_DUPLICATE_STRIPPED_PREFIX_NAMES_DIFFERENT_NAME_ALIAS = 2;
34}
35
36// This should result in an enum with these accessible values:
37// - Unknown = 0
38// - _2020 = 1
39// - _2021 = 2
40// - _2022 = 3
41enum TestEnumWithNumericNames {
42  TestEnumWithNumericNamesUNKNOWN = 0;
43  TestEnumWithNumericNames_2020 = 1;
44  TEST_ENUM_WITH_NUMERIC_NAMES_2021 = 2;
45  TEST_ENUM_WITH_NUMERIC_NAMES2022 = 3;
46}
47
48// This should result in an enum with these accessible values:
49// - Unknown = 0
50// - TestEnumValueNameSameAsEnum = 1
51enum TestEnumValueNameSameAsEnum {
52  TEST_ENUM_VALUE_NAME_SAME_AS_ENUM_UNKNOWN = 0;
53  TEST_ENUM_VALUE_NAME_SAME_AS_ENUM = 1;
54}
55
56// Regression test for maps with nested enum as value.
57message TestMapWithNestedEnum {
58  message InnerNested {
59    enum NestedEnum {
60      UNKNOWN = 0;
61      FOO = 1;
62    }
63  }
64  map<string, InnerNested.NestedEnum> string_map = 1;
65}
66