diff options
author | Joshua Haberman <jhaberman@gmail.com> | 2016-04-06 16:49:18 -0700 |
---|---|---|
committer | Joshua Haberman <jhaberman@gmail.com> | 2016-04-06 16:49:18 -0700 |
commit | 458077ccb4f7eddc94549528c3a9809745982352 (patch) | |
tree | 39cb7c59737895b757c0a830b166d6ed69e83027 /tests/test_cpp.cc | |
parent | d0b9d0a9b782e46a483d4d72515f9ab4f72e402a (diff) | |
parent | 8823fa6069452c86325b4d5a6065a0d4fd67f1a2 (diff) |
Merge pull request #53 from haberman/filedef
Added upb::FileDef, which represents the file defs are declared in.
Diffstat (limited to 'tests/test_cpp.cc')
-rw-r--r-- | tests/test_cpp.cc | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/tests/test_cpp.cc b/tests/test_cpp.cc index 48f0a3f..c27526b 100644 --- a/tests/test_cpp.cc +++ b/tests/test_cpp.cc @@ -6,6 +6,7 @@ #include <stdio.h> #include <string.h> +#include <fstream> #include <iostream> #include <set> #include <sstream> @@ -144,12 +145,22 @@ static void TestCastsConst10() { } static void TestSymbolTable(const char *descriptor_file) { - upb::reffed_ptr<upb::SymbolTable> s(upb::SymbolTable::New()); upb::Status status; - if (!upb::LoadDescriptorFileIntoSymtab(s.get(), descriptor_file, &status)) { + std::ifstream file_in(descriptor_file, std::ios::binary); + std::string descriptor((std::istreambuf_iterator<char>(file_in)), + (std::istreambuf_iterator<char>())); + std::vector<upb::reffed_ptr<upb::FileDef> > files; + if (!upb::LoadDescriptor(descriptor, &status, &files)) { std::cerr << "Couldn't load descriptor: " << status.error_message(); exit(1); } + + upb::reffed_ptr<upb::SymbolTable> s(upb::SymbolTable::New()); + + for (size_t i = 0; i < files.size(); i++) { + ASSERT(s->AddFile(files[i].get(), &status)); + } + ASSERT(!s->IsFrozen()); s->Freeze(); ASSERT(s->IsFrozen()); |