Index: net/der/parser_unittest.cc |
diff --git a/net/der/parser_unittest.cc b/net/der/parser_unittest.cc |
index 1943d6b86ebeb8fa79e1aa5df8147152e30d1681..10dac493978bde5deb86b344ec63e9818c5bcb51 100644 |
--- a/net/der/parser_unittest.cc |
+++ b/net/der/parser_unittest.cc |
@@ -196,6 +196,39 @@ TEST(ParserTest, CannotAdvanceAfterReadOptionalTag) { |
ASSERT_FALSE(parser.Advance()); |
} |
+TEST(ParserTest, ReadBitString) { |
+ const uint8_t der[] = {0x03, 0x03, 0x01, 0xAA, 0xBE}; |
+ Parser parser((Input(der))); |
+ |
+ Input bytes; |
+ uint8_t unused_bits; |
+ ASSERT_TRUE(parser.ReadBitString(&bytes, &unused_bits)); |
+ ASSERT_FALSE(parser.HasMore()); |
nharper
2015/07/21 23:23:47
EXPECT_FALSE
eroman
2015/07/22 17:05:23
Done.
|
+ |
+ ASSERT_EQ(2u, bytes.Length()); |
+ ASSERT_EQ(1u, unused_bits); |
+ ASSERT_EQ(0xAA, bytes.UnsafeData()[0]); |
+ ASSERT_EQ(0xBE, bytes.UnsafeData()[1]); |
nharper
2015/07/21 23:23:47
EXPECT_EQ (for lines 209-211)
Only parser.ReadBitS
eroman
2015/07/22 17:05:23
Done.
|
+} |
+ |
+TEST(ParserTest, ReadBitString_BadTag) { |
+ const uint8_t der[] = {0x05, 0x03, 0x01, 0xAA, 0xBE}; |
+ Parser parser((Input(der))); |
+ |
+ Input bytes; |
+ uint8_t unused_bits; |
+ ASSERT_FALSE(parser.ReadBitString(&bytes, &unused_bits)); |
+} |
+ |
+// Reads a BIT STRING with one unused bit -- should fail. |
+TEST(ParserTest, ReadBitStringNoUnusedBits) { |
+ const uint8_t der[] = {0x03, 0x03, 0x01, 0xAA, 0xBE}; |
+ Parser parser((Input(der))); |
+ |
+ Input bytes; |
+ ASSERT_FALSE(parser.ReadBitStringNoUnusedBits(&bytes)); |
+} |
+ |
} // namespace test |
} // namespace der |
} // namespace net |