Index: webrtc/p2p/base/stun_unittest.cc |
diff --git a/webrtc/p2p/base/stun_unittest.cc b/webrtc/p2p/base/stun_unittest.cc |
index efc11b240874f137918945baebcf84cdf72d916a..15d4648f276f4483b33f398063138c16267c401c 100644 |
--- a/webrtc/p2p/base/stun_unittest.cc |
+++ b/webrtc/p2p/base/stun_unittest.cc |
@@ -1016,6 +1016,15 @@ TEST_F(StunTest, ReadErrorCodeAttribute) { |
EXPECT_EQ(kTestErrorNumber, errorcode->number()); |
EXPECT_EQ(kTestErrorReason, errorcode->reason()); |
EXPECT_EQ(kTestErrorCode, errorcode->code()); |
+ EXPECT_EQ(kTestErrorCode, msg.GetErrorCodeValue()); |
+} |
+ |
+// Test that GetErrorCodeValue returns STUN_ERROR_GLOBAL_FAILURE if the message |
+// in question doesn't have an error code attribute, rather than crashing. |
+TEST_F(StunTest, GetErrorCodeValueWithNoErrorAttribute) { |
+ StunMessage msg; |
+ ReadStunMessage(&msg, kStunMessageWithIPv6MappedAddress); |
+ EXPECT_EQ(STUN_ERROR_GLOBAL_FAILURE, msg.GetErrorCodeValue()); |
} |
TEST_F(StunTest, ReadMessageWithAUInt16ListAttribute) { |