xref: /aosp_15_r20/external/truth/core/src/test/java/com/google/common/truth/BaseSubjectTestCase.java (revision b3996a89512f34bffd8f9a69f0bc726f1b19016a)
1 /*
2  * Copyright (c) 2017 Google, Inc.
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 package com.google.common.truth;
17 
18 import static com.google.common.truth.ExpectFailure.assertThat;
19 
20 /** Base class for truth subject tests to extend. */
21 abstract class BaseSubjectTestCase extends PlatformBaseSubjectTestCase {
assertFailureKeys(String... keys)22   final void assertFailureKeys(String... keys) {
23     assertThatFailure().factKeys().containsExactlyElementsIn(keys).inOrder();
24   }
25 
assertFailureValue(String key, String value)26   final void assertFailureValue(String key, String value) {
27     assertThatFailure().factValue(key).isEqualTo(value);
28   }
29 
assertFailureValueIndexed(String key, int index, String value)30   final void assertFailureValueIndexed(String key, int index, String value) {
31     assertThatFailure().factValue(key, index).isEqualTo(value);
32   }
33 
assertThatFailure()34   final TruthFailureSubject assertThatFailure() {
35     return assertThat(expectFailure.getFailure());
36   }
37 }
38