• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_TESTS_CONTAINER_TEST_UTIL_H_
6 #define MOJO_PUBLIC_CPP_BINDINGS_TESTS_CONTAINER_TEST_UTIL_H_
7 
8 #include <stddef.h>
9 
10 #include "base/macros.h"
11 
12 namespace mojo {
13 
14 class CopyableType {
15  public:
16   CopyableType();
17   CopyableType(const CopyableType& other);
18   CopyableType& operator=(const CopyableType& other);
19   ~CopyableType();
20 
copied()21   bool copied() const { return copied_; }
num_instances()22   static size_t num_instances() { return num_instances_; }
ptr()23   CopyableType* ptr() const { return ptr_; }
ResetCopied()24   void ResetCopied() { copied_ = false; }
25 
26  private:
27   bool copied_;
28   static size_t num_instances_;
29   CopyableType* ptr_;
30 };
31 
32 class MoveOnlyType {
33  public:
34   typedef MoveOnlyType Data_;
35   MoveOnlyType();
36   MoveOnlyType(MoveOnlyType&& other);
37   MoveOnlyType& operator=(MoveOnlyType&& other);
38   ~MoveOnlyType();
39 
moved()40   bool moved() const { return moved_; }
num_instances()41   static size_t num_instances() { return num_instances_; }
ptr()42   MoveOnlyType* ptr() const { return ptr_; }
ResetMoved()43   void ResetMoved() { moved_ = false; }
44 
45  private:
46   bool moved_;
47   static size_t num_instances_;
48   MoveOnlyType* ptr_;
49 
50   DISALLOW_COPY_AND_ASSIGN(MoveOnlyType);
51 };
52 
53 }  // namespace mojo
54 
55 #endif  // MOJO_PUBLIC_CPP_BINDINGS_TESTS_CONTAINER_TEST_UTIL_H_
56