Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(310)

Unified Diff: test/cctest/test-utils.cc

Issue 113992: fix embedded vector copy constructor and assignment. (Closed)
Patch Set: Created 11 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/utils.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-utils.cc
diff --git a/test/cctest/test-utils.cc b/test/cctest/test-utils.cc
index acb5d3ca68552905cc8ce3a64dd8a44cfafa7b12..7fd1044bf3e5f29f9798869c471bbf74187ad57e 100644
--- a/test/cctest/test-utils.cc
+++ b/test/cctest/test-utils.cc
@@ -177,3 +177,32 @@ TEST(SNPrintF) {
buffer.Dispose();
}
}
+
+
+// Issue 358: When copying EmbeddedVector, Vector::start_ must point
+// to the buffer in the copy, not in the source.
+TEST(EmbeddedVectorCopy) {
+ EmbeddedVector<int, 1> src;
+ src[0] = 100;
+ EmbeddedVector<int, 1> dst = src;
+ CHECK_NE(src.start(), dst.start());
+ CHECK_EQ(src[0], dst[0]);
+ src[0] = 200;
+ CHECK_NE(src[0], dst[0]);
+}
+
+
+// Also Issue 358, assignment case.
+TEST(EmbeddedVectorAssign) {
+ EmbeddedVector<int, 1> src;
+ src[0] = 100;
+ EmbeddedVector<int, 1> dst;
+ dst[0] = 200;
+ CHECK_NE(src.start(), dst.start());
+ CHECK_NE(src[0], dst[0]);
+ dst = src;
+ CHECK_NE(src.start(), dst.start());
+ CHECK_EQ(src[0], dst[0]);
+ src[0] = 200;
+ CHECK_NE(src[0], dst[0]);
+}
« no previous file with comments | « src/utils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698