WIP: introduced expanded net name

This commit is contained in:
Matthias Koefferlein
2018-12-27 10:43:25 +01:00
parent 639b0026d3
commit 8b2902c31b
6 changed files with 37 additions and 12 deletions
@@ -405,20 +405,9 @@ private:
hier_clusters_type m_net_clusters;
};
// @@@ TODO: move this somewhere else
static std::string net_name (const db::Net *net)
{
if (! net) {
return "(null)";
} else if (net->name ().empty ()) {
if (net->cluster_id () > std::numeric_limits<size_t>::max () / 2) {
return "$I" + tl::to_string ((std::numeric_limits<size_t>::max () - net->cluster_id ()) + 1);
} else {
return "$" + tl::to_string (net->cluster_id ());
}
} else {
return net->name ();
}
return net ? net->expanded_name () : "(null)";
}
static std::string device_name (const db::Device &device)
+5
View File
@@ -547,6 +547,11 @@ TEST(6_Net)
n2 = n;
EXPECT_EQ (n2.name (), "n");
EXPECT_EQ (int (n2.cluster_id ()), 17);
EXPECT_EQ (n2.expanded_name (), "n");
n2.set_name ("");
EXPECT_EQ (n2.expanded_name (), "$17");
n2.set_cluster_id (std::numeric_limits<size_t>::max () - 2);
EXPECT_EQ (n2.expanded_name (), "$I3");
n.clear ();
EXPECT_EQ (n.name (), "");