Commit 0404a592 authored by JINMEI Tatuya's avatar JINMEI Tatuya
Browse files

[master] don't initialize test data objects in namescope level.

this caused statici initialization fiasco for some build, e.g.:
http://git.bind10.isc.org/~tester/builder/BIND10/20130508225127-MacOSX10.6-x86_64-Clang-Static/logs/unittests.out

string objects moved inside the compare tests did not actually cause harm
in this environment, but should be generally better to be initialized
this way for the same reason.

while it's not a kind of 5-line patch, it should be pretty straightforward,
so I'm committing it at my discretion.
parent c6603dec
......@@ -47,15 +47,15 @@ template<> RRTYPE<generic::DLV>::RRTYPE() : RRType(RRType::DLV()) {}
template <class DS_LIKE>
class Rdata_DS_LIKE_Test : public RdataTest {
protected:
static DS_LIKE const rdata_ds_like;
Rdata_DS_LIKE_Test() :
ds_like_txt("12892 5 2 F1E184C0E1D615D20EB3C223ACED3B03C773DD952D"
"5F0EB5C777586DE18DA6B5"),
rdata_ds_like(ds_like_txt)
{}
const string ds_like_txt;
const DS_LIKE rdata_ds_like;
};
string ds_like_txt("12892 5 2 F1E184C0E1D615D20EB3C223ACED3B03C773DD952D"
"5F0EB5C777586DE18DA6B5");
template <class DS_LIKE>
DS_LIKE const Rdata_DS_LIKE_Test<DS_LIKE>::rdata_ds_like(ds_like_txt);
// The list of types we want to test.
typedef testing::Types<generic::DS, generic::DLV> Implementations;
......@@ -70,7 +70,7 @@ TYPED_TEST(Rdata_DS_LIKE_Test, createFromText) {
}
TYPED_TEST(Rdata_DS_LIKE_Test, toText_DS_LIKE) {
EXPECT_EQ(ds_like_txt, this->rdata_ds_like.toText());
EXPECT_EQ(this->ds_like_txt, this->rdata_ds_like.toText());
}
TYPED_TEST(Rdata_DS_LIKE_Test, badText_DS_LIKE) {
......@@ -96,7 +96,7 @@ TYPED_TEST(Rdata_DS_LIKE_Test, createFromWire_DS_LIKE) {
TYPED_TEST(Rdata_DS_LIKE_Test, createFromLexer_DS_LIKE) {
EXPECT_EQ(0, this->rdata_ds_like.compare(
*test::createRdataUsingLexer(RRTYPE<TypeParam>(), RRClass::IN(),
ds_like_txt)));
this->ds_like_txt)));
// Whitespace is okay
EXPECT_EQ(0, this->rdata_ds_like.compare(
......@@ -121,13 +121,13 @@ TYPED_TEST(Rdata_DS_LIKE_Test, createFromLexer_DS_LIKE) {
}
TYPED_TEST(Rdata_DS_LIKE_Test, assignment_DS_LIKE) {
TypeParam copy((string(ds_like_txt)));
TypeParam copy(this->ds_like_txt);
copy = this->rdata_ds_like;
EXPECT_EQ(0, copy.compare(this->rdata_ds_like));
// Check if the copied data is valid even after the original is deleted
TypeParam* copy2 = new TypeParam(this->rdata_ds_like);
TypeParam copy3((string(ds_like_txt)));
TypeParam copy3(this->ds_like_txt);
copy3 = *copy2;
delete copy2;
EXPECT_EQ(0, copy3.compare(this->rdata_ds_like));
......@@ -143,7 +143,7 @@ TYPED_TEST(Rdata_DS_LIKE_Test, getTag_DS_LIKE) {
TYPED_TEST(Rdata_DS_LIKE_Test, toWireRenderer) {
Rdata_DS_LIKE_Test<TypeParam>::renderer.skip(2);
TypeParam rdata_ds_like(ds_like_txt);
TypeParam rdata_ds_like(this->ds_like_txt);
rdata_ds_like.toWire(this->renderer);
vector<unsigned char> data;
......@@ -156,7 +156,7 @@ TYPED_TEST(Rdata_DS_LIKE_Test, toWireRenderer) {
}
TYPED_TEST(Rdata_DS_LIKE_Test, toWireBuffer) {
TypeParam rdata_ds_like(ds_like_txt);
TypeParam rdata_ds_like(this->ds_like_txt);
rdata_ds_like.toWire(this->obuffer);
}
......@@ -179,8 +179,33 @@ string ds_like_txt6("12892 5 2 F2E184C0E1D615D20EB3C223ACED3B03C773DD952D"
"5F0EB5C777586DE18DA6B555");
TYPED_TEST(Rdata_DS_LIKE_Test, compare) {
const string ds_like_txt1(
"12892 5 2 F1E184C0E1D615D20EB3C223ACED3B03C773DD952D"
"5F0EB5C777586DE18DA6B5");
// different tag
const string ds_like_txt2(
"12893 5 2 F1E184C0E1D615D20EB3C223ACED3B03C773DD952D"
"5F0EB5C777586DE18DA6B5");
// different algorithm
const string ds_like_txt3(
"12892 6 2 F1E184C0E1D615D20EB3C223ACED3B03C773DD952D"
"5F0EB5C777586DE18DA6B5");
// different digest type
const string ds_like_txt4(
"12892 5 3 F1E184C0E1D615D20EB3C223ACED3B03C773DD952D"
"5F0EB5C777586DE18DA6B5");
// different digest
const string ds_like_txt5(
"12892 5 2 F2E184C0E1D615D20EB3C223ACED3B03C773DD952D"
"5F0EB5C777586DE18DA6B5");
// different digest length
const string ds_like_txt6(
"12892 5 2 F2E184C0E1D615D20EB3C223ACED3B03C773DD952D"
"5F0EB5C777586DE18DA6B555");
// trivial case: self equivalence
EXPECT_EQ(0, TypeParam(ds_like_txt).compare(TypeParam(ds_like_txt)));
EXPECT_EQ(0, TypeParam(this->ds_like_txt).
compare(TypeParam(this->ds_like_txt)));
// non-equivalence tests
EXPECT_LT(TypeParam(ds_like_txt1).compare(TypeParam(ds_like_txt2)), 0);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment