OLD | NEW |
| (Empty) |
1 // Copyright 2013 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 #include "base/win/scoped_handle.h" | |
6 #include "testing/gtest/include/gtest/gtest.h" | |
7 | |
8 void CreateHandle(int value, HANDLE* result) { | |
9 *result = reinterpret_cast<HANDLE>(value); | |
10 } | |
11 | |
12 TEST(ScopedHandleTest, Receive) { | |
13 base::win::ScopedHandle handle; | |
14 int value = 51; | |
15 | |
16 { | |
17 // This is not really the expected use case, but it is a very explicit test. | |
18 base::win::ScopedHandle::Receiver a = handle.Receive(); | |
19 HANDLE* pointer = a; | |
20 *pointer = reinterpret_cast<HANDLE>(value); | |
21 } | |
22 | |
23 EXPECT_EQ(handle.Get(), reinterpret_cast<HANDLE>(value)); | |
24 HANDLE to_discard = handle.Take(); | |
25 | |
26 // The standard use case: | |
27 value = 183; | |
28 CreateHandle(value, handle.Receive()); | |
29 EXPECT_EQ(handle.Get(), reinterpret_cast<HANDLE>(value)); | |
30 to_discard = handle.Take(); | |
31 } | |
OLD | NEW |