1 // Copyright (c) 2012 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.
5 #include "base/win/scoped_handle.h"
6 #include "testing/gtest/include/gtest/gtest.h"
8 void CreateHandle(int value, HANDLE* result) {
9 *result = reinterpret_cast<HANDLE>(value);
12 TEST(ScopedHandleTest, Receive) {
13 base::win::ScopedHandle handle;
17 // This is not really the expected use case, but it is a very explicit test.
18 base::win::ScopedHandle::Receiver a = handle.Receive();
20 *pointer = reinterpret_cast<HANDLE>(value);
23 EXPECT_EQ(handle.Get(), reinterpret_cast<HANDLE>(value));
24 HANDLE to_discard = handle.Take();
26 // The standard use case:
28 CreateHandle(value, handle.Receive());
29 EXPECT_EQ(handle.Get(), reinterpret_cast<HANDLE>(value));
30 to_discard = handle.Take();