summaryrefslogtreecommitdiff
path: root/android/test_asserts.go
diff options
context:
space:
mode:
author Anton Hansson <hansson@google.com> 2021-04-21 16:30:10 +0100
committer Anton Hansson <hansson@google.com> 2021-04-22 10:20:13 +0100
commitdae54cd84fff352cd1479314758cfd077da79e16 (patch)
treed06b994d32f468781c10cebab6e8986add1c2b34 /android/test_asserts.go
parentb21166e236e757fb1cd3db648fbc034a51817fef (diff)
Add new stub_only_static_libs attr for sdk_library
Allow java_sdk_libraries to include libraries statically into their stubs. The immediate use-case of this is to embed libcore notice files into their stubs. Also extend the java_sdk_library tests for impl/stub-only-libs, plus some not assert utils. Bug: 173186484 Bug: 184839599 Test: soong tests Change-Id: I1ebf2f35c048eab5cec5125482a0304fe660f188
Diffstat (limited to 'android/test_asserts.go')
-rw-r--r--android/test_asserts.go37
1 files changed, 34 insertions, 3 deletions
diff --git a/android/test_asserts.go b/android/test_asserts.go
index bfb88ab17..edeb40889 100644
--- a/android/test_asserts.go
+++ b/android/test_asserts.go
@@ -126,13 +126,44 @@ func AssertStringDoesNotContain(t *testing.T, message string, s string, unexpect
}
}
+// AssertStringContainsEquals checks if the string contains or does not contain the substring, given
+// the value of the expected bool. If the expectation does not hold it reports an error prefixed with
+// the supplied message and including a reason for why it failed.
+func AssertStringContainsEquals(t *testing.T, message string, s string, substring string, expected bool) {
+ if expected {
+ AssertStringDoesContain(t, message, s, substring)
+ } else {
+ AssertStringDoesNotContain(t, message, s, substring)
+ }
+}
+
// AssertStringListContains checks if the list of strings contains the expected string. If it does
// not then it reports an error prefixed with the supplied message and including a reason for why it
// failed.
-func AssertStringListContains(t *testing.T, message string, list []string, expected string) {
+func AssertStringListContains(t *testing.T, message string, list []string, s string) {
+ t.Helper()
+ if !InList(s, list) {
+ t.Errorf("%s: could not find %q within %q", message, s, list)
+ }
+}
+
+// AssertStringListDoesNotContain checks if the list of strings contains the expected string. If it does
+// then it reports an error prefixed with the supplied message and including a reason for why it failed.
+func AssertStringListDoesNotContain(t *testing.T, message string, list []string, s string) {
t.Helper()
- if !InList(expected, list) {
- t.Errorf("%s: could not find %q within %q", message, expected, list)
+ if InList(s, list) {
+ t.Errorf("%s: unexpectedly found %q within %q", message, s, list)
+ }
+}
+
+// AssertStringContainsEquals checks if the string contains or does not contain the substring, given
+// the value of the expected bool. If the expectation does not hold it reports an error prefixed with
+// the supplied message and including a reason for why it failed.
+func AssertStringListContainsEquals(t *testing.T, message string, list []string, s string, expected bool) {
+ if expected {
+ AssertStringListContains(t, message, list, s)
+ } else {
+ AssertStringListDoesNotContain(t, message, list, s)
}
}