File size: 684 Bytes
f61bac1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <exception>

#include "gtest/gtest.h"
#include "helper.h"
#include "odb/db.h"

namespace odb {
namespace {

TEST_F(SimpleDbFixture, test_delete_module)
{
  createSimpleDB();

  auto and2 = db_->findMaster("and2");
  ASSERT_NE(and2, nullptr);

  auto inst = dbInst::create(db_->getChip()->getBlock(), and2, "i1");

  // Can't delete while there is an instance of the master
  EXPECT_THROW(dbMaster::destroy(and2), std::exception);

  dbInst::destroy(inst);
  dbMaster::destroy(and2);  // now we can

  // It is gone
  for (auto lib : db_->getLibs()) {
    for (auto master : lib->getMasters()) {
      EXPECT_NE(master, and2);
    }
  }
}

}  // namespace
}  // namespace odb