Browse Source

[2522] add some SSHFP negative-value unit tests

Paul Selkirk 12 years ago
parent
commit
29b82a61f1
1 changed files with 13 additions and 5 deletions
  1. 13 5
      src/lib/dns/tests/rdata_sshfp_unittest.cc

+ 13 - 5
src/lib/dns/tests/rdata_sshfp_unittest.cc

@@ -48,6 +48,11 @@ protected:
             rdata_str, rdata_sshfp, false, false);
     }
 
+    void checkFromText_InvalidText(const string& rdata_str) {
+        checkFromText<generic::SSHFP, InvalidRdataText, InvalidRdataText>(
+            rdata_str, rdata_sshfp, true, true);
+    }
+
     void checkFromText_LexerError(const string& rdata_str) {
         checkFromText
             <generic::SSHFP, InvalidRdataText, MasterLexer::LexerError>(
@@ -125,6 +130,14 @@ TEST_F(Rdata_SSHFP_Test, badText) {
     checkFromText_LexerError("1 TWO 123456789abcdef67890123456789abcdef67890");
     checkFromText_BadValue("1 2 BUCKLEMYSHOE");
     checkFromText_BadString(sshfp_txt + " extra text");
+
+    // yes, these are redundant to the last test cases in algorithmTypes
+    checkFromText_InvalidText("2345 1 123456789abcdef67890123456789abcdef67890");
+    checkFromText_InvalidText("2 1234 123456789abcdef67890123456789abcdef67890");
+
+    // negative values are trapped in the lexer rather than the constructor
+    checkFromText_LexerError("-2 1 123456789abcdef67890123456789abcdef67890");
+    checkFromText_LexerError("2 -1 123456789abcdef67890123456789abcdef67890");
 }
 
 TEST_F(Rdata_SSHFP_Test, copy) {
@@ -186,11 +199,6 @@ TEST_F(Rdata_SSHFP_Test, createFromParams) {
     EXPECT_EQ(0, rdata_sshfp2.compare(rdata_sshfp));
 }
 
-TEST_F(Rdata_SSHFP_Test, createByCopy) {
-    const generic::SSHFP rdata_sshfp2(rdata_sshfp);
-    EXPECT_EQ(0, rdata_sshfp2.compare(rdata_sshfp));
-}
-
 TEST_F(Rdata_SSHFP_Test, toText) {
     EXPECT_TRUE(boost::iequals(sshfp_txt, rdata_sshfp.toText()));