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

Unified Diff: base/bind_unittest.cc

Issue 1537553002: Replace typedef with using for Callback/Bind related files (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years 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 | « base/bind_internal_win.h ('k') | base/bind_unittest.nc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/bind_unittest.cc
diff --git a/base/bind_unittest.cc b/base/bind_unittest.cc
index 4c80001d94fe9fd96cb0648857e6d85a8c8b839f..32c2c4a598ceb1119a6ace8d7c8c1384208b5c87 100644
--- a/base/bind_unittest.cc
+++ b/base/bind_unittest.cc
@@ -27,11 +27,11 @@ class NoRef {
public:
NoRef() {}
- MOCK_METHOD0(VoidMethod0, void(void));
- MOCK_CONST_METHOD0(VoidConstMethod0, void(void));
+ MOCK_METHOD0(VoidMethod0, void());
+ MOCK_CONST_METHOD0(VoidConstMethod0, void());
- MOCK_METHOD0(IntMethod0, int(void));
- MOCK_CONST_METHOD0(IntConstMethod0, int(void));
+ MOCK_METHOD0(IntMethod0, int());
+ MOCK_CONST_METHOD0(IntConstMethod0, int());
private:
// Particularly important in this test to ensure no copies are made.
@@ -42,8 +42,8 @@ class HasRef : public NoRef {
public:
HasRef() {}
- MOCK_CONST_METHOD0(AddRef, void(void));
- MOCK_CONST_METHOD0(Release, bool(void));
+ MOCK_CONST_METHOD0(AddRef, void());
+ MOCK_CONST_METHOD0(Release, bool());
private:
// Particularly important in this test to ensure no copies are made.
@@ -60,8 +60,8 @@ static const int kChildValue = 2;
class Parent {
public:
- void AddRef(void) const {}
- void Release(void) const {}
+ void AddRef() const {}
+ void Release() const {}
virtual void VirtualSet() { value = kParentValue; }
void NonVirtualSet() { value = kParentValue; }
int value;
@@ -230,11 +230,11 @@ class BindTest : public ::testing::Test {
virtual ~BindTest() {
}
- static void VoidFunc0(void) {
+ static void VoidFunc0() {
static_func_mock_ptr->VoidMethod0();
}
- static int IntFunc0(void) { return static_func_mock_ptr->IntMethod0(); }
+ static int IntFunc0() { return static_func_mock_ptr->IntMethod0(); }
protected:
StrictMock<NoRef> no_ref_;
@@ -254,7 +254,7 @@ StrictMock<NoRef>* BindTest::static_func_mock_ptr;
// Sanity check that we can instantiate a callback for each arity.
TEST_F(BindTest, ArityTest) {
- Callback<int(void)> c0 = Bind(&Sum, 32, 16, 8, 4, 2, 1);
+ Callback<int()> c0 = Bind(&Sum, 32, 16, 8, 4, 2, 1);
EXPECT_EQ(63, c0.Run());
Callback<int(int)> c1 = Bind(&Sum, 32, 16, 8, 4, 2);
@@ -296,7 +296,7 @@ TEST_F(BindTest, CurryingTest) {
Callback<int(int)> c1 = Bind(c2, 2);
EXPECT_EQ(75, c1.Run(13));
- Callback<int(void)> c0 = Bind(c1, 1);
+ Callback<int()> c0 = Bind(c1, 1);
EXPECT_EQ(63, c0.Run());
}
@@ -337,7 +337,7 @@ TEST_F(BindTest, FunctionTypeSupport) {
EXPECT_CALL(has_ref_, VoidConstMethod0()).Times(2);
Closure normal_cb = Bind(&VoidFunc0);
- Callback<NoRef*(void)> normal_non_refcounted_cb =
+ Callback<NoRef*()> normal_non_refcounted_cb =
Bind(&PolymorphicIdentity<NoRef*>, &no_ref_);
normal_cb.Run();
EXPECT_EQ(&no_ref_, normal_non_refcounted_cb.Run());
@@ -379,11 +379,11 @@ TEST_F(BindTest, ReturnValues) {
.WillOnce(Return(41337))
.WillOnce(Return(51337));
- Callback<int(void)> normal_cb = Bind(&IntFunc0);
- Callback<int(void)> method_cb = Bind(&HasRef::IntMethod0, &has_ref_);
- Callback<int(void)> const_method_nonconst_obj_cb =
+ Callback<int()> normal_cb = Bind(&IntFunc0);
+ Callback<int()> method_cb = Bind(&HasRef::IntMethod0, &has_ref_);
+ Callback<int()> const_method_nonconst_obj_cb =
Bind(&HasRef::IntConstMethod0, &has_ref_);
- Callback<int(void)> const_method_const_obj_cb =
+ Callback<int()> const_method_const_obj_cb =
Bind(&HasRef::IntConstMethod0, const_has_ref_ptr_);
EXPECT_EQ(1337, normal_cb.Run());
EXPECT_EQ(31337, method_cb.Run());
@@ -447,46 +447,46 @@ TEST_F(BindTest, IgnoreResult) {
TEST_F(BindTest, ArgumentBinding) {
int n = 2;
- Callback<int(void)> bind_primitive_cb = Bind(&Identity, n);
+ Callback<int()> bind_primitive_cb = Bind(&Identity, n);
EXPECT_EQ(n, bind_primitive_cb.Run());
- Callback<int*(void)> bind_primitive_pointer_cb =
+ Callback<int*()> bind_primitive_pointer_cb =
Bind(&PolymorphicIdentity<int*>, &n);
EXPECT_EQ(&n, bind_primitive_pointer_cb.Run());
- Callback<int(void)> bind_int_literal_cb = Bind(&Identity, 3);
+ Callback<int()> bind_int_literal_cb = Bind(&Identity, 3);
EXPECT_EQ(3, bind_int_literal_cb.Run());
- Callback<const char*(void)> bind_string_literal_cb =
+ Callback<const char*()> bind_string_literal_cb =
Bind(&CStringIdentity, "hi");
EXPECT_STREQ("hi", bind_string_literal_cb.Run());
- Callback<int(void)> bind_template_function_cb =
+ Callback<int()> bind_template_function_cb =
Bind(&PolymorphicIdentity<int>, 4);
EXPECT_EQ(4, bind_template_function_cb.Run());
NoRefParent p;
p.value = 5;
- Callback<int(void)> bind_object_cb = Bind(&UnwrapNoRefParent, p);
+ Callback<int()> bind_object_cb = Bind(&UnwrapNoRefParent, p);
EXPECT_EQ(5, bind_object_cb.Run());
IncompleteType* incomplete_ptr = reinterpret_cast<IncompleteType*>(123);
- Callback<IncompleteType*(void)> bind_incomplete_ptr_cb =
+ Callback<IncompleteType*()> bind_incomplete_ptr_cb =
Bind(&PolymorphicIdentity<IncompleteType*>, incomplete_ptr);
EXPECT_EQ(incomplete_ptr, bind_incomplete_ptr_cb.Run());
NoRefChild c;
c.value = 6;
- Callback<int(void)> bind_promotes_cb = Bind(&UnwrapNoRefParent, c);
+ Callback<int()> bind_promotes_cb = Bind(&UnwrapNoRefParent, c);
EXPECT_EQ(6, bind_promotes_cb.Run());
c.value = 7;
- Callback<int(void)> bind_pointer_promotes_cb =
+ Callback<int()> bind_pointer_promotes_cb =
Bind(&UnwrapNoRefParentPtr, &c);
EXPECT_EQ(7, bind_pointer_promotes_cb.Run());
c.value = 8;
- Callback<int(void)> bind_const_reference_promotes_cb =
+ Callback<int()> bind_const_reference_promotes_cb =
Bind(&UnwrapNoRefParentConstRef, c);
EXPECT_EQ(8, bind_const_reference_promotes_cb.Run());
}
@@ -533,12 +533,12 @@ TEST_F(BindTest, ReferenceArgumentBinding) {
int& ref_n = n;
const int& const_ref_n = n;
- Callback<int(void)> ref_copies_cb = Bind(&Identity, ref_n);
+ Callback<int()> ref_copies_cb = Bind(&Identity, ref_n);
EXPECT_EQ(n, ref_copies_cb.Run());
n++;
EXPECT_EQ(n - 1, ref_copies_cb.Run());
- Callback<int(void)> const_ref_copies_cb = Bind(&Identity, const_ref_n);
+ Callback<int()> const_ref_copies_cb = Bind(&Identity, const_ref_n);
EXPECT_EQ(n, const_ref_copies_cb.Run());
n++;
EXPECT_EQ(n - 1, const_ref_copies_cb.Run());
@@ -551,10 +551,10 @@ TEST_F(BindTest, ArrayArgumentBinding) {
int array[4] = {1, 1, 1, 1};
const int (*const_array_ptr)[4] = &array;
- Callback<int(void)> array_cb = Bind(&ArrayGet, array, 1);
+ Callback<int()> array_cb = Bind(&ArrayGet, array, 1);
EXPECT_EQ(1, array_cb.Run());
- Callback<int(void)> const_array_cb = Bind(&ArrayGet, *const_array_ptr, 1);
+ Callback<int()> const_array_cb = Bind(&ArrayGet, *const_array_ptr, 1);
EXPECT_EQ(1, const_array_cb.Run());
array[1] = 3;
@@ -592,15 +592,15 @@ TEST_F(BindTest, Unretained) {
EXPECT_CALL(no_ref_, VoidMethod0());
EXPECT_CALL(no_ref_, VoidConstMethod0()).Times(2);
- Callback<void(void)> method_cb =
+ Callback<void()> method_cb =
Bind(&NoRef::VoidMethod0, Unretained(&no_ref_));
method_cb.Run();
- Callback<void(void)> const_method_cb =
+ Callback<void()> const_method_cb =
Bind(&NoRef::VoidConstMethod0, Unretained(&no_ref_));
const_method_cb.Run();
- Callback<void(void)> const_method_const_ptr_cb =
+ Callback<void()> const_method_const_ptr_cb =
Bind(&NoRef::VoidConstMethod0, Unretained(const_no_ref_ptr_));
const_method_const_ptr_cb.Run();
}
@@ -652,8 +652,8 @@ TEST_F(BindTest, WeakPtr) {
TEST_F(BindTest, ConstRef) {
int n = 1;
- Callback<int(void)> copy_cb = Bind(&Identity, n);
- Callback<int(void)> const_ref_cb = Bind(&Identity, ConstRef(n));
+ Callback<int()> copy_cb = Bind(&Identity, n);
+ Callback<int()> const_ref_cb = Bind(&Identity, ConstRef(n));
EXPECT_EQ(n, copy_cb.Run());
EXPECT_EQ(n, const_ref_cb.Run());
n++;
@@ -663,7 +663,7 @@ TEST_F(BindTest, ConstRef) {
int copies = 0;
int assigns = 0;
CopyCounter counter(&copies, &assigns);
- Callback<int(void)> all_const_ref_cb =
+ Callback<int()> all_const_ref_cb =
Bind(&GetCopies, ConstRef(counter));
EXPECT_EQ(0, all_const_ref_cb.Run());
EXPECT_EQ(0, copies);
@@ -680,7 +680,7 @@ TEST_F(BindTest, ScopedRefptr) {
const scoped_refptr<StrictMock<HasRef> > refptr(&has_ref_);
- Callback<int(void)> scoped_refptr_const_ref_cb =
+ Callback<int()> scoped_refptr_const_ref_cb =
Bind(&FunctionWithScopedRefptrFirstParam, base::ConstRef(refptr), 1);
EXPECT_EQ(1, scoped_refptr_const_ref_cb.Run());
}
@@ -692,7 +692,7 @@ TEST_F(BindTest, Owned) {
// If we don't capture, delete happens on Callback destruction/reset.
// return the same value.
- Callback<DeleteCounter*(void)> no_capture_cb =
+ Callback<DeleteCounter*()> no_capture_cb =
Bind(&PolymorphicIdentity<DeleteCounter*>, Owned(counter));
ASSERT_EQ(counter, no_capture_cb.Run());
ASSERT_EQ(counter, no_capture_cb.Run());
@@ -721,7 +721,7 @@ TEST_F(BindTest, ScopedPtr) {
// Tests the Passed() function's support for pointers.
scoped_ptr<DeleteCounter> ptr(new DeleteCounter(&deletes));
- Callback<scoped_ptr<DeleteCounter>(void)> unused_callback =
+ Callback<scoped_ptr<DeleteCounter>()> unused_callback =
Bind(&PassThru<scoped_ptr<DeleteCounter> >, Passed(&ptr));
EXPECT_FALSE(ptr.get());
EXPECT_EQ(0, deletes);
@@ -733,7 +733,7 @@ TEST_F(BindTest, ScopedPtr) {
// Tests the Passed() function's support for rvalues.
deletes = 0;
DeleteCounter* counter = new DeleteCounter(&deletes);
- Callback<scoped_ptr<DeleteCounter>(void)> callback =
+ Callback<scoped_ptr<DeleteCounter>()> callback =
Bind(&PassThru<scoped_ptr<DeleteCounter> >,
Passed(scoped_ptr<DeleteCounter>(counter)));
EXPECT_FALSE(ptr.get());
@@ -764,7 +764,7 @@ TEST_F(BindTest, UniquePtr) {
// Tests the Passed() function's support for pointers.
std::unique_ptr<DeleteCounter> ptr(new DeleteCounter(&deletes));
- Callback<std::unique_ptr<DeleteCounter>(void)> unused_callback =
+ Callback<std::unique_ptr<DeleteCounter>()> unused_callback =
Bind(&PassThru<std::unique_ptr<DeleteCounter>>, Passed(&ptr));
EXPECT_FALSE(ptr.get());
EXPECT_EQ(0, deletes);
@@ -776,7 +776,7 @@ TEST_F(BindTest, UniquePtr) {
// Tests the Passed() function's support for rvalues.
deletes = 0;
DeleteCounter* counter = new DeleteCounter(&deletes);
- Callback<std::unique_ptr<DeleteCounter>(void)> callback =
+ Callback<std::unique_ptr<DeleteCounter>()> callback =
Bind(&PassThru<std::unique_ptr<DeleteCounter>>,
Passed(std::unique_ptr<DeleteCounter>(counter)));
EXPECT_FALSE(ptr.get());
@@ -813,7 +813,7 @@ TEST_F(BindTest, ArgumentCopies) {
CopyCounter counter(&copies, &assigns);
- Callback<void(void)> copy_cb =
+ Callback<void()> copy_cb =
Bind(&VoidPolymorphic<CopyCounter>::Run, counter);
EXPECT_GE(1, copies);
EXPECT_EQ(0, assigns);
@@ -855,10 +855,10 @@ int __stdcall StdCallFunc(int n) {
// - Can bind a __fastcall function.
// - Can bind a __stdcall function.
TEST_F(BindTest, WindowsCallingConventions) {
- Callback<int(void)> fastcall_cb = Bind(&FastCallFunc, 1);
+ Callback<int()> fastcall_cb = Bind(&FastCallFunc, 1);
EXPECT_EQ(1, fastcall_cb.Run());
- Callback<int(void)> stdcall_cb = Bind(&StdCallFunc, 2);
+ Callback<int()> stdcall_cb = Bind(&StdCallFunc, 2);
EXPECT_EQ(2, stdcall_cb.Run());
}
#endif
« no previous file with comments | « base/bind_internal_win.h ('k') | base/bind_unittest.nc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698