aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/TArrayTest.cpp
diff options
context:
space:
mode:
authorGravatar Greg Daniel <egdaniel@google.com>2017-03-22 13:33:21 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-03-22 18:33:19 +0000
commit70131b97f97f97d6fbcf4545b97827dfe8509654 (patch)
tree73da517a55a7b3121dfab19de799869fec82d111 /tests/TArrayTest.cpp
parentdbd11ec106e3726b09bf5d240c9fcbf6a671a570 (diff)
Fix SkTArray operator= to work with self assignment
BUG=skia: Change-Id: I2a403a7ccbb87a030757f3e57d2ea53503f72512 Reviewed-on: https://skia-review.googlesource.com/10012 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Greg Daniel <egdaniel@google.com>
Diffstat (limited to 'tests/TArrayTest.cpp')
-rw-r--r--tests/TArrayTest.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/TArrayTest.cpp b/tests/TArrayTest.cpp
index 6e23c49b35..0e18e9f96d 100644
--- a/tests/TArrayTest.cpp
+++ b/tests/TArrayTest.cpp
@@ -281,6 +281,19 @@ void test_unnecessary_alloc(skiatest::Reporter* reporter) {
}
}
+static void test_self_assignment(skiatest::Reporter* reporter) {
+ SkTArray<int> a;
+ a.push_back(1);
+ REPORTER_ASSERT(reporter, !a.empty());
+ REPORTER_ASSERT(reporter, a.count() == 1);
+ REPORTER_ASSERT(reporter, a[0] == 1);
+
+ a = a;
+ REPORTER_ASSERT(reporter, !a.empty());
+ REPORTER_ASSERT(reporter, a.count() == 1);
+ REPORTER_ASSERT(reporter, a[0] == 1);
+}
+
DEF_TEST(TArray, reporter) {
TestTSet_basic<true>(reporter);
TestTSet_basic<false>(reporter);
@@ -296,4 +309,6 @@ DEF_TEST(TArray, reporter) {
test_move(reporter);
test_unnecessary_alloc(reporter);
+
+ test_self_assignment(reporter);
}