~ubuntu-branches/debian/wheezy/protobuf/wheezy

« back to all changes in this revision

Viewing changes to src/google/protobuf/descriptor_database_unittest.cc

  • Committer: Bazaar Package Importer
  • Author(s): Robert S. Edmonds
  • Date: 2010-01-25 18:14:49 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20100125181449-98wvlw14imerlej8
Tags: 2.3.0-1
* New upstream version.
* Split out libprotobuf-lite from the libprotobuf package.
* Add CFLAGS specific to sh4; closes: #560322.

Show diffs side-by-side

added added

removed removed

Lines of Context:
480
480
 
481
481
#endif  // GTEST_HAS_PARAM_TEST
482
482
 
 
483
TEST(EncodedDescriptorDatabaseExtraTest, FindNameOfFileContainingSymbol) {
 
484
  // Create two files, one of which is in two parts.
 
485
  FileDescriptorProto file1, file2a, file2b;
 
486
  file1.set_name("foo.proto");
 
487
  file1.set_package("foo");
 
488
  file1.add_message_type()->set_name("Foo");
 
489
  file2a.set_name("bar.proto");
 
490
  file2b.set_package("bar");
 
491
  file2b.add_message_type()->set_name("Bar");
 
492
 
 
493
  // Normal serialization allows our optimization to kick in.
 
494
  string data1 = file1.SerializeAsString();
 
495
 
 
496
  // Force out-of-order serialization to test slow path.
 
497
  string data2 = file2b.SerializeAsString() + file2a.SerializeAsString();
 
498
 
 
499
  // Create EncodedDescriptorDatabase containing both files.
 
500
  EncodedDescriptorDatabase db;
 
501
  db.Add(data1.data(), data1.size());
 
502
  db.Add(data2.data(), data2.size());
 
503
 
 
504
  // Test!
 
505
  string filename;
 
506
  EXPECT_TRUE(db.FindNameOfFileContainingSymbol("foo.Foo", &filename));
 
507
  EXPECT_EQ("foo.proto", filename);
 
508
  EXPECT_TRUE(db.FindNameOfFileContainingSymbol("foo.Foo.Blah", &filename));
 
509
  EXPECT_EQ("foo.proto", filename);
 
510
  EXPECT_TRUE(db.FindNameOfFileContainingSymbol("bar.Bar", &filename));
 
511
  EXPECT_EQ("bar.proto", filename);
 
512
  EXPECT_FALSE(db.FindNameOfFileContainingSymbol("foo", &filename));
 
513
  EXPECT_FALSE(db.FindNameOfFileContainingSymbol("bar", &filename));
 
514
  EXPECT_FALSE(db.FindNameOfFileContainingSymbol("baz.Baz", &filename));
 
515
}
 
516
 
483
517
// ===================================================================
484
518
 
485
519
class MergedDescriptorDatabaseTest : public testing::Test {