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

Side by Side Diff: util/win/handle_test.cc

Issue 1422503015: win: Add HandleToInt() and IntToHandle() (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Created 5 years, 1 month 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Crashpad Authors. All rights reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 #include "util/win/handle.h"
16
17 #include <stdint.h>
18
19 #include <limits>
20
21 #include "gtest/gtest.h"
22
23 namespace crashpad {
24 namespace test {
25 namespace {
26
27 TEST(Handle, HandleToInt) {
28 EXPECT_EQ(0, HandleToInt(nullptr));
29 EXPECT_EQ(-1, HandleToInt(INVALID_HANDLE_VALUE));
30 EXPECT_EQ(1, HandleToInt(reinterpret_cast<HANDLE>(1)));
31 EXPECT_EQ(std::numeric_limits<int>::max(),
32 HandleToInt(reinterpret_cast<HANDLE>(
33 static_cast<intptr_t>(std::numeric_limits<int>::max()))));
34 EXPECT_EQ(std::numeric_limits<int>::min(),
35 HandleToInt(reinterpret_cast<HANDLE>(
36 static_cast<intptr_t>(std::numeric_limits<int>::min()))));
37 }
38
39 TEST(Handle, IntToHandle) {
40 EXPECT_EQ(nullptr, IntToHandle(0));
41 EXPECT_EQ(INVALID_HANDLE_VALUE, IntToHandle(-1));
42 EXPECT_EQ(reinterpret_cast<HANDLE>(1), IntToHandle(1));
43 EXPECT_EQ(reinterpret_cast<HANDLE>(
44 static_cast<intptr_t>(std::numeric_limits<int>::max())),
45 IntToHandle(std::numeric_limits<int>::max()));
46 EXPECT_EQ(reinterpret_cast<HANDLE>(
47 static_cast<intptr_t>(std::numeric_limits<int>::min())),
48 IntToHandle(std::numeric_limits<int>::min()));
49 }
50
51 } // namespace
52 } // namespace test
53 } // namespace crashpad
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698