Parcourir la source

[master] Avoid static init fiasco in libdns++ unittests due to merge of #2390, #2656

Mukund Sivaraman il y a 12 ans
Parent
commit
fbb78097f3

+ 8 - 3
src/lib/dns/tests/rdata_cname_unittest.cc

@@ -33,11 +33,16 @@ using namespace isc::dns::rdata;
 
 namespace {
 class Rdata_CNAME_Test : public RdataTest {
-    // there's nothing to specialize
+public:
+    Rdata_CNAME_Test() :
+        rdata_cname("cn.example.com."),
+        rdata_cname2("cn2.example.com.")
+    {}
+
+    const generic::CNAME rdata_cname;
+    const generic::CNAME rdata_cname2;
 };
 
-const generic::CNAME rdata_cname("cn.example.com.");
-const generic::CNAME rdata_cname2("cn2.example.com.");
 const uint8_t wiredata_cname[] = {
     0x02, 0x63, 0x6e, 0x07, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x03,
     0x63, 0x6f, 0x6d, 0x00 };

+ 8 - 3
src/lib/dns/tests/rdata_dname_unittest.cc

@@ -33,11 +33,16 @@ using namespace isc::dns::rdata;
 
 namespace {
 class Rdata_DNAME_Test : public RdataTest {
-    // there's nothing to specialize
+public:
+    Rdata_DNAME_Test() :
+        rdata_dname("dn.example.com."),
+        rdata_dname2("dn2.example.com.")
+    {}
+
+    const generic::DNAME rdata_dname;
+    const generic::DNAME rdata_dname2;
 };
 
-const generic::DNAME rdata_dname("dn.example.com.");
-const generic::DNAME rdata_dname2("dn2.example.com.");
 const uint8_t wiredata_dname[] = {
     0x02, 0x64, 0x6e, 0x07, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x03,
     0x63, 0x6f, 0x6d, 0x00 };

+ 6 - 3
src/lib/dns/tests/rdata_mx_unittest.cc

@@ -32,10 +32,13 @@ using namespace isc::dns::rdata;
 
 namespace {
 class Rdata_MX_Test : public RdataTest {
-    // there's nothing to specialize
-};
+public:
+    Rdata_MX_Test() :
+        rdata_mx(10, Name("mx.example.com"))
+    {}
 
-const generic::MX rdata_mx(10, Name("mx.example.com"));
+    const generic::MX rdata_mx;
+};
 
 TEST_F(Rdata_MX_Test, createFromText) {
     const generic::MX rdata_mx2("10 mx.example.com.");

+ 8 - 3
src/lib/dns/tests/rdata_ns_unittest.cc

@@ -33,11 +33,16 @@ using namespace isc::dns::rdata;
 
 namespace {
 class Rdata_NS_Test : public RdataTest {
-    // there's nothing to specialize
+public:
+    Rdata_NS_Test() :
+        rdata_ns("ns.example.com."),
+        rdata_ns2("ns2.example.com.")
+    {}
+
+    const generic::NS rdata_ns;
+    const generic::NS rdata_ns2;
 };
 
-const generic::NS rdata_ns("ns.example.com.");
-const generic::NS rdata_ns2("ns2.example.com.");
 const uint8_t wiredata_ns[] = {
     0x02, 0x6e, 0x73, 0x07, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x03,
     0x63, 0x6f, 0x6d, 0x00 };

+ 8 - 3
src/lib/dns/tests/rdata_ptr_unittest.cc

@@ -37,11 +37,16 @@ using namespace isc::dns::rdata;
 
 namespace {
 class Rdata_PTR_Test : public RdataTest {
-    // there's nothing to specialize
+public:
+     Rdata_PTR_Test() :
+         rdata_ptr("ns.example.com."),
+         rdata_ptr2("ns2.example.com.")
+     {}
+
+     const generic::PTR rdata_ptr;
+     const generic::PTR rdata_ptr2;
 };
 
-const generic::PTR rdata_ptr("ns.example.com.");
-const generic::PTR rdata_ptr2("ns2.example.com.");
 const uint8_t wiredata_ptr[] = {
     0x02, 0x6e, 0x73, 0x07, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x03,
     0x63, 0x6f, 0x6d, 0x00 };

+ 15 - 9
src/lib/dns/tests/rdata_srv_unittest.cc

@@ -33,14 +33,23 @@ using namespace isc::dns::rdata;
 
 namespace {
 class Rdata_SRV_Test : public RdataTest {
-    // there's nothing to specialize
+public:
+    Rdata_SRV_Test() :
+        srv_txt("1 5 1500 a.example.com."),
+        srv_txt2("1 5 1400 example.com."),
+        too_long_label("012345678901234567890123456789"
+                       "0123456789012345678901234567890123."),
+        rdata_srv(srv_txt),
+        rdata_srv2(srv_txt2)
+    {}
+
+    const string srv_txt;
+    const string srv_txt2;
+    const string too_long_label;
+    const in::SRV rdata_srv;
+    const in::SRV rdata_srv2;
 };
 
-string srv_txt("1 5 1500 a.example.com.");
-string srv_txt2("1 5 1400 example.com.");
-string too_long_label("012345678901234567890123456789"
-    "0123456789012345678901234567890123.");
-
 // 1 5 1500 a.example.com.
 const uint8_t wiredata_srv[] = {
     0x00, 0x01, 0x00, 0x05, 0x05, 0xdc, 0x01, 0x61, 0x07, 0x65, 0x78,
@@ -50,9 +59,6 @@ const uint8_t wiredata_srv2[] = {
     0x00, 0x01, 0x00, 0x05, 0x05, 0x78, 0x07, 0x65, 0x78, 0x61, 0x6d,
     0x70, 0x6c, 0x65, 0x03, 0x63, 0x6f, 0x6d, 0x00};
 
-const in::SRV rdata_srv(srv_txt);
-const in::SRV rdata_srv2(srv_txt2);
-
 TEST_F(Rdata_SRV_Test, createFromText) {
     EXPECT_EQ(1, rdata_srv.getPriority());
     EXPECT_EQ(5, rdata_srv.getWeight());