aboutsummaryrefslogtreecommitdiff
path: root/test/common
diff options
context:
space:
mode:
authorColin Snover2017-05-24 23:12:23 -0500
committerColin Snover2017-06-08 10:45:55 -0500
commit58c83dcd140137cf5c5808a95e7b0711fa556933 (patch)
tree022ced757e426daa9f9abafd82df6bb84fd261d2 /test/common
parente29f60858dc4172f91d235219e76a9e13e4d72f9 (diff)
downloadscummvm-rg350-58c83dcd140137cf5c5808a95e7b0711fa556933.tar.gz
scummvm-rg350-58c83dcd140137cf5c5808a95e7b0711fa556933.tar.bz2
scummvm-rg350-58c83dcd140137cf5c5808a95e7b0711fa556933.zip
COMMON: Make SpanOwner copy assignment make a copy of the owned Span
To move data from one SpanOwner to another, use `moveFrom`. Thanks @waltervn for pointing out the problem.
Diffstat (limited to 'test/common')
-rw-r--r--test/common/span.h21
1 files changed, 19 insertions, 2 deletions
diff --git a/test/common/span.h b/test/common/span.h
index aa3ee9d22f..1c1a0adcda 100644
--- a/test/common/span.h
+++ b/test/common/span.h
@@ -269,9 +269,26 @@ public:
{
Common::SpanOwner<Common::Span<byte> > owner2;
+ TS_ASSERT(owner2->data() == nullptr);
+ owner2 = owner;
+ TS_ASSERT(owner2->data() != nullptr);
+ TS_ASSERT_DIFFERS(owner->data(), owner2->data());
+
+ for (int i = 0; i < 3; ++i) {
+ TS_ASSERT_EQUALS(owner2->getUint8At(i), 'a' + i);
+ TS_ASSERT_EQUALS((*owner2)[i], 'a' + i);
+ }
+
+ TS_ASSERT_EQUALS((bool)owner2, true);
+ owner2.release();
+ TS_ASSERT_EQUALS((bool)owner2, false);
+ }
+
+ {
+ Common::SpanOwner<Common::Span<byte> > owner2;
TS_ASSERT_EQUALS((bool)owner, true);
void *dataPtr = owner->data();
- owner2 = owner;
+ owner2.moveFrom(owner);
TS_ASSERT_EQUALS((bool)owner, false);
TS_ASSERT(owner->data() == nullptr);
TS_ASSERT_EQUALS(owner2->data(), dataPtr);
@@ -350,7 +367,7 @@ public:
Common::SpanOwner<Common::NamedSpan<byte> > owner2;
TS_ASSERT_EQUALS((bool)owner, true);
void *dataPtr = owner->data();
- owner2 = owner;
+ owner2.moveFrom(owner);
TS_ASSERT_EQUALS((bool)owner, false);
TS_ASSERT(owner->data() == nullptr);
TS_ASSERT_EQUALS(owner2->data(), dataPtr);