blob: 16488ae62deb8f89e83a344b14b2636725dc267e [file] [log] [blame]
Kevin Rocardf0357882017-02-10 16:19:28 -08001/*
2 * Copyright (C) 2017 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#include <hidl/Status.h>
17
18namespace detail {
19
20inline void assertOk(::android::hardware::Return<void> ret) {
21 ASSERT_TRUE(ret.isOk());
22}
23
24inline void assertOk(::android::hardware::audio::V2_0::Result result) {
25 ASSERT_EQ(decltype(result)::OK, result);
26}
27
28inline void assertOk(::android::hardware::Return<::android::hardware::audio::V2_0::Result> ret) {
29 ASSERT_TRUE(ret.isOk());
30 ::android::hardware::audio::V2_0::Result result = ret;
31 assertOk(result);
32}
33
Kevin Rocard3c405a72017-03-08 16:46:51 -080034inline void assertInvalidArguments(::android::hardware::audio::V2_0::Result result) {
35 ASSERT_EQ(decltype(result)::INVALID_ARGUMENTS, result);
36}
37
38inline void assertInvalidArguments(
39 ::android::hardware::Return<::android::hardware::audio::V2_0::Result> ret) {
40 ASSERT_TRUE(ret.isOk());
41 ::android::hardware::audio::V2_0::Result result = ret;
42 assertInvalidArguments(result);
43}
Kevin Rocardf0357882017-02-10 16:19:28 -080044}
45
46// Test anything provided is and contains only OK
47#define ASSERT_OK(ret) ASSERT_NO_FATAL_FAILURE(detail::assertOk(ret))
48#define EXPECT_OK(ret) EXPECT_NO_FATAL_FAILURE(detail::assertOk(ret))
Kevin Rocard3c405a72017-03-08 16:46:51 -080049
50#define ASSERT_INVALID_ARGUMENTS(ret) ASSERT_NO_FATAL_FAILURE(detail::assertInvalidArguments(ret))