Bug 1048642, Part 3: Remove SECStatus GTest utilities, r=cviecco
authorBrian Smith <brian@briansmith.org>
Sun, 03 Aug 2014 22:45:05 -0700
changeset 14650 ffe4741a32ef7aa695f3590de6c37e314bb0e819
parent 14649 91860e48f97b7554945495e611c293cb87f41375
child 14651 636639b0f0b199a261caacac54c73af4657993e0
push id3202
push userfranziskuskiefer@gmail.com
push dateMon, 01 Oct 2018 08:30:12 +0000
reviewerscviecco
bugs1048642
Bug 1048642, Part 3: Remove SECStatus GTest utilities, r=cviecco
lib/mozpkix/test/gtest/nssgtest.cpp
lib/mozpkix/test/gtest/nssgtest.h
--- a/lib/mozpkix/test/gtest/nssgtest.cpp
+++ b/lib/mozpkix/test/gtest/nssgtest.cpp
@@ -27,62 +27,16 @@
 #include "pkixtestutil.h"
 #include "prinit.h"
 
 using namespace std;
 using namespace testing;
 
 namespace mozilla { namespace pkix { namespace test {
 
-ostream&
-operator<<(ostream& os, SECStatusWithPRErrorCode const& value)
-{
-  switch (value.mRv)
-  {
-    case SECSuccess:
-      os << "SECSuccess";
-      break;
-    case SECWouldBlock:
-      os << "SECWouldBlock";
-      break;
-    case SECFailure:
-      os << "SECFailure";
-      break;
-    default:
-      os << "[Invalid SECStatus: " << static_cast<int64_t>(value.mRv) << ']';
-      break;
-  }
-
-  if (value.mRv != SECSuccess) {
-    os << '(';
-    const char* name = PR_ErrorToName(value.mErrorCode);
-    if (name) {
-      os << name;
-    } else {
-      os << value.mErrorCode;
-    }
-    os << ')';
-  }
-
-  return os;
-}
-
-AssertionResult
-Pred_SECFailure(const char* expectedExpr, const char* actualExpr,
-                PRErrorCode expectedErrorCode, SECStatus actual)
-{
-  if (SECFailure == actual && expectedErrorCode == PR_GetError()) {
-    return AssertionSuccess();
-  }
-
-  return AssertionFailure()
-      << "Expected: (" << expectedExpr << ") == (" << actualExpr
-      << "), actual: " << SECFailure << " != " << actual;
-}
-
 /*static*/ void
 NSSTest::SetUpTestCase()
 {
   if (NSS_NoDB_Init(nullptr) != SECSuccess) {
     PR_Abort();
   }
 
   now = Now();
--- a/lib/mozpkix/test/gtest/nssgtest.h
+++ b/lib/mozpkix/test/gtest/nssgtest.h
@@ -40,65 +40,16 @@ PORT_FreeArena_false(PLArenaPool* arena)
 {
   // PL_FreeArenaPool can't be used because it doesn't actually free the
   // memory, which doesn't work well with memory analysis tools
   return PORT_FreeArena(arena, PR_FALSE);
 }
 
 typedef ScopedPtr<PLArenaPool, PORT_FreeArena_false> ScopedPLArenaPool;
 
-class SECStatusWithPRErrorCode
-{
-public:
-  SECStatusWithPRErrorCode(SECStatus rv, PRErrorCode errorCode)
-    : mRv(rv)
-    , mErrorCode(errorCode)
-  {
-  }
-
-  explicit SECStatusWithPRErrorCode(SECStatus rv)
-    : mRv(rv)
-    , mErrorCode(rv == SECSuccess ? 0 : PR_GetError())
-  {
-  }
-
-  bool operator==(const SECStatusWithPRErrorCode& other) const
-  {
-    return mRv == other.mRv && mErrorCode == other.mErrorCode;
-  }
-
-private:
-  const SECStatus mRv;
-  const PRErrorCode mErrorCode;
-
-  friend std::ostream& operator<<(std::ostream& os,
-                                  SECStatusWithPRErrorCode const& value);
-
-  void operator=(const SECStatusWithPRErrorCode&) /*= delete*/;
-};
-
-::std::ostream& operator<<(::std::ostream&,
-                           SECStatusWithPRErrorCode const&);
-
-#define ASSERT_SECSuccess(rv) \
-  ASSERT_EQ(::mozilla::pkix::test::SECStatusWithPRErrorCode(SECSuccess, 0), \
-            ::mozilla::pkix::test::SECStatusWithPRErrorCode(rv))
-#define EXPECT_SECSuccess(rv) \
-  EXPECT_EQ(::mozilla::pkix::test::SECStatusWithPRErrorCode(SECSuccess, 0), \
-            ::mozilla::pkix::test::SECStatusWithPRErrorCode(rv))
-
-#define ASSERT_SECFailure(expectedError, rv) \
-  ASSERT_EQ(::mozilla::pkix::test::SECStatusWithPRErrorCode(SECFailure, \
-                                                            expectedError), \
-            ::mozilla::pkix::test::SECStatusWithPRErrorCode(rv))
-#define EXPECT_SECFailure(expectedError, rv) \
-  EXPECT_EQ(::mozilla::pkix::test::SECStatusWithPRErrorCode(SECFailure, \
-                                                            expectedError), \
-            ::mozilla::pkix::test::SECStatusWithPRErrorCode(rv))
-
 class NSSTest : public ::testing::Test
 {
 public:
   static void SetUpTestCase();
 
 protected:
   NSSTest();