OLD | NEW |
1 // Copyright 2014 The Crashpad Authors. All rights reserved. | 1 // Copyright 2014 The Crashpad Authors. All rights reserved. |
2 // | 2 // |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
4 // you may not use this file except in compliance with 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 | 5 // You may obtain a copy of the License at |
6 // | 6 // |
7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
8 // | 8 // |
9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 EXPECT_EQ(0x08u, uuid.data_4[0]); | 63 EXPECT_EQ(0x08u, uuid.data_4[0]); |
64 EXPECT_EQ(0x09u, uuid.data_4[1]); | 64 EXPECT_EQ(0x09u, uuid.data_4[1]); |
65 EXPECT_EQ(0x0au, uuid.data_5[0]); | 65 EXPECT_EQ(0x0au, uuid.data_5[0]); |
66 EXPECT_EQ(0x0bu, uuid.data_5[1]); | 66 EXPECT_EQ(0x0bu, uuid.data_5[1]); |
67 EXPECT_EQ(0x0cu, uuid.data_5[2]); | 67 EXPECT_EQ(0x0cu, uuid.data_5[2]); |
68 EXPECT_EQ(0x0du, uuid.data_5[3]); | 68 EXPECT_EQ(0x0du, uuid.data_5[3]); |
69 EXPECT_EQ(0x0eu, uuid.data_5[4]); | 69 EXPECT_EQ(0x0eu, uuid.data_5[4]); |
70 EXPECT_EQ(0x0fu, uuid.data_5[5]); | 70 EXPECT_EQ(0x0fu, uuid.data_5[5]); |
71 EXPECT_EQ("00010203-0405-0607-0809-0a0b0c0d0e0f", uuid.ToString()); | 71 EXPECT_EQ("00010203-0405-0607-0809-0a0b0c0d0e0f", uuid.ToString()); |
72 | 72 |
| 73 // Test both operator== and operator!=. |
| 74 EXPECT_FALSE(uuid == uuid_zero); |
| 75 EXPECT_NE(uuid, uuid_zero); |
| 76 |
| 77 UUID uuid_2(kBytes); |
| 78 EXPECT_EQ(uuid, uuid_2); |
| 79 EXPECT_FALSE(uuid != uuid_2); |
| 80 |
| 81 // Make sure that operator== and operator!= check the entire UUID. |
| 82 ++uuid.data_1; |
| 83 EXPECT_NE(uuid, uuid_2); |
| 84 --uuid.data_1; |
| 85 ++uuid.data_2; |
| 86 EXPECT_NE(uuid, uuid_2); |
| 87 --uuid.data_2; |
| 88 ++uuid.data_3; |
| 89 EXPECT_NE(uuid, uuid_2); |
| 90 --uuid.data_3; |
| 91 for (size_t index = 0; index < arraysize(uuid.data_4); ++index) { |
| 92 ++uuid.data_4[index]; |
| 93 EXPECT_NE(uuid, uuid_2); |
| 94 --uuid.data_4[index]; |
| 95 } |
| 96 for (size_t index = 0; index < arraysize(uuid.data_5); ++index) { |
| 97 ++uuid.data_5[index]; |
| 98 EXPECT_NE(uuid, uuid_2); |
| 99 --uuid.data_5[index]; |
| 100 } |
| 101 |
| 102 // Make sure that the UUIDs are equal again, otherwise the test above may not |
| 103 // have been valid. |
| 104 EXPECT_EQ(uuid, uuid_2); |
| 105 |
73 const uint8_t kMoreBytes[16] = {0xff, | 106 const uint8_t kMoreBytes[16] = {0xff, |
74 0xee, | 107 0xee, |
75 0xdd, | 108 0xdd, |
76 0xcc, | 109 0xcc, |
77 0xbb, | 110 0xbb, |
78 0xaa, | 111 0xaa, |
79 0x99, | 112 0x99, |
80 0x88, | 113 0x88, |
81 0x77, | 114 0x77, |
82 0x66, | 115 0x66, |
(...skipping 10 matching lines...) Expand all Loading... |
93 EXPECT_EQ(0x77u, uuid.data_4[0]); | 126 EXPECT_EQ(0x77u, uuid.data_4[0]); |
94 EXPECT_EQ(0x66u, uuid.data_4[1]); | 127 EXPECT_EQ(0x66u, uuid.data_4[1]); |
95 EXPECT_EQ(0x55u, uuid.data_5[0]); | 128 EXPECT_EQ(0x55u, uuid.data_5[0]); |
96 EXPECT_EQ(0x44u, uuid.data_5[1]); | 129 EXPECT_EQ(0x44u, uuid.data_5[1]); |
97 EXPECT_EQ(0x33u, uuid.data_5[2]); | 130 EXPECT_EQ(0x33u, uuid.data_5[2]); |
98 EXPECT_EQ(0x22u, uuid.data_5[3]); | 131 EXPECT_EQ(0x22u, uuid.data_5[3]); |
99 EXPECT_EQ(0x11u, uuid.data_5[4]); | 132 EXPECT_EQ(0x11u, uuid.data_5[4]); |
100 EXPECT_EQ(0x00u, uuid.data_5[5]); | 133 EXPECT_EQ(0x00u, uuid.data_5[5]); |
101 EXPECT_EQ("ffeeddcc-bbaa-9988-7766-554433221100", uuid.ToString()); | 134 EXPECT_EQ("ffeeddcc-bbaa-9988-7766-554433221100", uuid.ToString()); |
102 | 135 |
| 136 EXPECT_NE(uuid, uuid_2); |
| 137 EXPECT_NE(uuid, uuid_zero); |
| 138 |
103 // Test that UUID is standard layout. | 139 // Test that UUID is standard layout. |
104 memset(&uuid, 0x45, 16); | 140 memset(&uuid, 0x45, 16); |
105 EXPECT_EQ(0x45454545u, uuid.data_1); | 141 EXPECT_EQ(0x45454545u, uuid.data_1); |
106 EXPECT_EQ(0x4545u, uuid.data_2); | 142 EXPECT_EQ(0x4545u, uuid.data_2); |
107 EXPECT_EQ(0x4545u, uuid.data_3); | 143 EXPECT_EQ(0x4545u, uuid.data_3); |
108 EXPECT_EQ(0x45u, uuid.data_4[0]); | 144 EXPECT_EQ(0x45u, uuid.data_4[0]); |
109 EXPECT_EQ(0x45u, uuid.data_4[1]); | 145 EXPECT_EQ(0x45u, uuid.data_4[1]); |
110 EXPECT_EQ(0x45u, uuid.data_5[0]); | 146 EXPECT_EQ(0x45u, uuid.data_5[0]); |
111 EXPECT_EQ(0x45u, uuid.data_5[1]); | 147 EXPECT_EQ(0x45u, uuid.data_5[1]); |
112 EXPECT_EQ(0x45u, uuid.data_5[2]); | 148 EXPECT_EQ(0x45u, uuid.data_5[2]); |
113 EXPECT_EQ(0x45u, uuid.data_5[3]); | 149 EXPECT_EQ(0x45u, uuid.data_5[3]); |
114 EXPECT_EQ(0x45u, uuid.data_5[4]); | 150 EXPECT_EQ(0x45u, uuid.data_5[4]); |
115 EXPECT_EQ(0x45u, uuid.data_5[5]); | 151 EXPECT_EQ(0x45u, uuid.data_5[5]); |
116 EXPECT_EQ("45454545-4545-4545-4545-454545454545", uuid.ToString()); | 152 EXPECT_EQ("45454545-4545-4545-4545-454545454545", uuid.ToString()); |
117 } | 153 } |
118 | 154 |
119 } // namespace | 155 } // namespace |
OLD | NEW |