C++11 Unit Test for RValue semantics.

Motivation:  test that these works on all possible bots and for all possible clients (clients do run these unit tests, right?)

Dear clients:  if this unit test fails, let us know!

BUG=skia:3427

Review URL: https://codereview.chromium.org/922043004
This commit is contained in:
halcanary 2015-02-13 15:12:52 -08:00 committed by Commit bot
parent ad66f9b15f
commit 3a6672ae0c
2 changed files with 27 additions and 0 deletions

View File

@ -74,6 +74,7 @@
'../tests/ColorFilterTest.cpp',
'../tests/ColorPrivTest.cpp',
'../tests/ColorTest.cpp',
'../tests/CPlusPlusEleven.cpp',
'../tests/DashPathEffectTest.cpp',
'../tests/DataRefTest.cpp',
'../tests/DeferredCanvasTest.cpp',

26
tests/CPlusPlusEleven.cpp Normal file
View File

@ -0,0 +1,26 @@
/*
* Copyright 2015 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "Test.h"
namespace {
template <class T> T&& Move(T& o) { return static_cast<T&&>(o); }
class Moveable {
public:
Moveable() {}
Moveable(Moveable&&) {}
Moveable& operator=(Moveable&&) { return *this; }
private:
Moveable(const Moveable&);
Moveable& operator=(const Moveable&);
};
} // namespace
DEF_TEST(CPlusPlusEleven_RvalueAndMove, r) {
Moveable src1; Moveable dst1(Move(src1));
Moveable src2, dst2; dst2 = Move(src2);
}