Browse Source

add test case in cpp_bootstrap_unittest.cc

Wang Kirin 6 years ago
parent
commit
f38b6ed041
1 changed files with 13 additions and 0 deletions
  1. 13 0
      src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc

+ 13 - 0
src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc

@@ -178,6 +178,19 @@ TEST(BootstrapTest, GeneratedFilesMatch) {
   }
 }
 
+//test Generate in cpp_generator.cc
+TEST(BootstrapTest, OptionNotExist)
+{
+  cpp::CppGenerator generator;
+  DescriptorPool pool;
+  GeneratorContext *generator_context = nullptr;
+  std::string parameter = "aaa";
+  string error;
+  ASSERT_FALSE(generator.Generate(pool.FindFileByName("google/protobuf/descriptor.proto"),
+                                  parameter, generator_context, &error));
+  EXPECT_EQ(error, "Unknown generator option: " + parameter);
+}
+
 }  // namespace
 
 }  // namespace cpp