Commit 58d40d96 authored by JINMEI Tatuya's avatar JINMEI Tatuya
Browse files

added test case for the maximum extended Rcode


git-svn-id: svn://bind10.isc.org/svn/bind10/trunk@1061 e5f2f494-b856-4b98-b285-d166d9295462
parent bec5512a
......@@ -14,6 +14,8 @@
// $Id$
#include <exceptions/exceptions.h>
#include <dns/buffer.h>
#include <dns/message.h>
#include <dns/messagerenderer.h>
......@@ -57,6 +59,25 @@ MessageTest::factoryFromFile(Message& message, const char* datafile)
message.fromWire(buffer);
}
TEST_F(MessageTest, RcodeConstruct)
{
// normal cases
EXPECT_EQ(0, Rcode(0).getCode());
EXPECT_EQ(0xfff, Rcode(0xfff).getCode()); // possible max code
// should fail on attempt of construction with an out of range code
EXPECT_THROW(Rcode(0x1000), isc::OutOfRange);
EXPECT_THROW(Rcode(0xffff), isc::OutOfRange);
}
TEST_F(MessageTest, RcodeToText)
{
EXPECT_EQ("NOERROR", Rcode::NOERROR().toText());
EXPECT_EQ("BADVERS", Rcode::BADVERS().toText());
EXPECT_EQ("17", Rcode(Rcode::BADVERS().getCode() + 1).toText());
EXPECT_EQ("4095", Rcode(Rcode(0xfff)).toText());
}
TEST_F(MessageTest, fromWire)
{
factoryFromFile(message, "testdata/message_fromWire1");
......@@ -125,6 +146,18 @@ TEST_F(MessageTest, EDNS0UDPSize)
EXPECT_EQ(Message::DEFAULT_MAX_UDPSIZE, message.getUDPSize());
}
TEST_F(MessageTest, EDNS0ExtCode)
{
// Extended Rcode = BADVERS
factoryFromFile(message, "testdata/message_fromWire10");
EXPECT_EQ(Rcode::BADVERS(), message.getRcode());
// Maximum extended Rcode
message.clear();
factoryFromFile(message, "testdata/message_fromWire11");
EXPECT_EQ(0xfff, message.getRcode().getCode());
}
TEST_F(MessageTest, BadEDNS0)
{
// OPT RR in the answer section
......
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