50
50
namespace google {
51
51
namespace protobuf {
52
52
namespace compiler {
53
+ namespace {
53
54
54
55
// Returns the list of the names of files in all_files in the form of a
55
56
// comma-separated string.
@@ -71,14 +72,20 @@ static constexpr absl::string_view kFirstInsertionPoint =
71
72
static constexpr absl::string_view kSecondInsertionPoint =
72
73
" # @@protoc_insertion_point(second_mock_insertion_point) is here\n " ;
73
74
74
- MockCodeGenerator::MockCodeGenerator ( absl::string_view name) : name_(name ) {
75
+ absl::string_view GetTestCase ( ) {
75
76
const char * c_key = getenv (" TEST_CASE" );
76
- if (c_key == NULL ) {
77
+ if (c_key == nullptr ) {
77
78
// In Windows, setting 'TEST_CASE=' is equivalent to unsetting
78
- // and therefore c_key can be NULL
79
- c_key = " " ;
79
+ // and therefore c_key can be nullptr
80
+ return " " ;
80
81
}
81
- absl::string_view key (c_key);
82
+ return c_key;
83
+ }
84
+
85
+ } // namespace
86
+
87
+ MockCodeGenerator::MockCodeGenerator (absl::string_view name) : name_(name) {
88
+ absl::string_view key = GetTestCase ();
82
89
if (key == " no_editions" ) {
83
90
suppressed_features_ |= CodeGenerator::FEATURE_SUPPORTS_EDITIONS;
84
91
} else if (key == " invalid_features" ) {
@@ -214,7 +221,7 @@ bool MockCodeGenerator::Generate(const FileDescriptor* file,
214
221
std::string* error) const {
215
222
// Override minimum/maximum after generating the pool to simulate a plugin
216
223
// that "works" but doesn't advertise support of the current edition.
217
- absl::string_view test_case = getenv ( " TEST_CASE " );
224
+ absl::string_view test_case = GetTestCase ( );
218
225
if (test_case == " high_minimum" ) {
219
226
minimum_edition_ = Edition::EDITION_99997_TEST_ONLY;
220
227
} else if (test_case == " low_maximum" ) {
0 commit comments