Ticket #47: name.diff

File name.diff, 1.6 KB (added by jinmei, 10 years ago)
  • name.h

     
    261261    /// \param buffer A buffer storing the wire format data.
    262262    /// \param downcase Whether to convert upper case alphabets to lower case.
    263263    explicit Name(InputBuffer& buffer, bool downcase = false);
     264    ///
     265    /// We use the default copy constructor intentionally.
    264266    //@}
     267    /// We use the default copy assignment operator intentionally.
     268    ///
    265269
    266270    ///
    267271    /// \name Getter Methods
  • name_unittest.cc

     
    266266                                  25).getLabelCount());
    267267}
    268268
     269TEST_F(NameTest, copyConstruct)
     270{
     271    Name copy(example_name);
     272    EXPECT_EQ(copy, example_name);
     273
     274    // Check the copied data is valid even after the original is deleted
     275    Name* copy2 = new Name(example_name);
     276    Name copy3(*copy2);
     277    delete copy2;
     278    EXPECT_EQ(copy3, example_name);
     279}
     280
     281TEST_F(NameTest, assignment)
     282{
     283    Name copy(".");
     284    copy = example_name;
     285    EXPECT_EQ(copy, example_name);
     286
     287    // Check if the copied data is valid even after the original is deleted
     288    Name* copy2 = new Name(example_name);
     289    Name copy3(".");
     290    copy3 = *copy2;
     291    delete copy2;
     292    EXPECT_EQ(copy3, example_name);
     293
     294    // Self assignment
     295    copy = copy;
     296    EXPECT_EQ(copy, example_name);
     297}
     298
    269299TEST_F(NameTest, toText)
    270300{
    271301    // tests derived from BIND9