Add CNumericMessage

This commit is contained in:
J-P Nurmi
2015-09-05 01:03:58 +02:00
parent 6f40e5ddca
commit fa894a86b0
3 changed files with 16 additions and 1 deletions
+5
View File
@@ -126,6 +126,11 @@ public:
void SetText(const CString& sText) { SetParam(1, sText); }
};
class CNumericMessage : public CMessage {
public:
unsigned int GetCode() const { return GetCommand().ToUInt(); }
};
class CKickMessage : public CTargetMessage {
public:
CString GetKickedNick() const { return GetParam(1); }
+2 -1
View File
@@ -182,8 +182,9 @@ void CIRCSock::ReadLine(const CString& sData) {
}
if ((sCmd.length() == 3) && (isdigit(sCmd[0])) && (isdigit(sCmd[1])) && (isdigit(sCmd[2]))) {
CNumericMessage& NumericMsg = static_cast<CNumericMessage&>(Message);
CString sServer = Message.GetNick().GetHostMask();
unsigned int uRaw = sCmd.ToUInt();
unsigned int uRaw = NumericMsg.GetCode();
CString sNick = Message.GetParam(0);
CString sRest = Message.GetParams(1);
CString sTmp;
+9
View File
@@ -189,6 +189,15 @@ TEST(MessageTest, Nick) {
EXPECT_EQ(":nick NICK test", msg.ToString());
}
TEST(MessageTest, Numeric) {
CNumericMessage msg;
msg.Parse(":server 123 user :foo bar");
EXPECT_EQ("server", msg.GetNick().GetNick());
EXPECT_EQ("123", msg.GetCommand());
EXPECT_EQ(123u, msg.GetCode());
EXPECT_EQ(CMessage::Type::Numeric, msg.GetType());
}
TEST(MessageTest, Part) {
CPartMessage msg;
msg.Parse(":nick PART #chan :reason");