1 /* 2 * Copyright (C) 2019 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #pragma once 18 19 #include <android/hardware/automotive/can/1.0/ICanController.h> 20 21 namespace android::hardware::automotive::can::V1_0 { 22 23 /** 24 * Define gTest printer for a given HIDL type, but skip definition for Return<T>. 25 */ 26 #define DEFINE_CAN_HAL_PRINTER_SIMPLE(T, converter) \ 27 std::ostream& operator<<(std::ostream& os, const T& v) { return os << converter(v); } 28 29 /** 30 * Define gTest printer for a given HIDL type. 31 */ 32 #define DEFINE_CAN_HAL_PRINTER(T, converter) \ 33 DEFINE_CAN_HAL_PRINTER_SIMPLE(T, converter) \ 34 std::ostream& operator<<(std::ostream& os, const Return<T>& v) { return os << converter(v); } 35 36 DEFINE_CAN_HAL_PRINTER(CanMessage, toString) 37 DEFINE_CAN_HAL_PRINTER(ErrorEvent, toString) 38 DEFINE_CAN_HAL_PRINTER(ICanController::BusConfig::InterfaceId, toString); 39 DEFINE_CAN_HAL_PRINTER(ICanController::InterfaceType, toString) 40 DEFINE_CAN_HAL_PRINTER(ICanController::Result, toString) 41 DEFINE_CAN_HAL_PRINTER(Result, toString) 42 43 #undef DEFINE_CAN_HAL_PRINTER 44 #undef DEFINE_CAN_HAL_PRINTER_SIMPLE 45 46 } // namespace android::hardware::automotive::can::V1_0 47