1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/security/pkix/test/gtest/pkixgtest.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,62 @@ 1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ 1.6 +/* This code is made available to you under your choice of the following sets 1.7 + * of licensing terms: 1.8 + */ 1.9 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.10 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.11 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. 1.12 + */ 1.13 +/* Copyright 2014 Mozilla Contributors 1.14 + * 1.15 + * Licensed under the Apache License, Version 2.0 (the "License"); 1.16 + * you may not use this file except in compliance with the License. 1.17 + * You may obtain a copy of the License at 1.18 + * 1.19 + * http://www.apache.org/licenses/LICENSE-2.0 1.20 + * 1.21 + * Unless required by applicable law or agreed to in writing, software 1.22 + * distributed under the License is distributed on an "AS IS" BASIS, 1.23 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1.24 + * See the License for the specific language governing permissions and 1.25 + * limitations under the License. 1.26 + */ 1.27 + 1.28 +#include "pkixgtest.h" 1.29 + 1.30 +namespace mozilla { namespace pkix { namespace test { 1.31 + 1.32 +std::ostream& 1.33 +operator<<(std::ostream& os, const ResultWithPRErrorCode& value) 1.34 +{ 1.35 + switch (value.mRv) 1.36 + { 1.37 + case Success: 1.38 + os << "Success"; 1.39 + break; 1.40 + case RecoverableError: 1.41 + os << "RecoverableError"; 1.42 + break; 1.43 + case SECFailure: 1.44 + os << "FatalError"; 1.45 + break; 1.46 + default: 1.47 + os << "[Invalid Result: " << static_cast<int64_t>(value.mRv) << ']'; 1.48 + break; 1.49 + } 1.50 + 1.51 + if (value.mRv != Success) { 1.52 + os << '('; 1.53 + const char* name = PR_ErrorToName(value.mErrorCode); 1.54 + if (name) { 1.55 + os << name; 1.56 + } else { 1.57 + os << value.mErrorCode; 1.58 + } 1.59 + os << ')'; 1.60 + } 1.61 + 1.62 + return os; 1.63 +} 1.64 + 1.65 +} } } // namespace mozilla::pkix::test