2014-08-01 14:39:55 -04:00
|
|
|
// Copyright 2014 The Crashpad Authors. All rights reserved.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
|
|
|
#include "util/misc/uuid.h"
|
|
|
|
|
2016-01-06 12:22:50 -05:00
|
|
|
#include <string.h>
|
|
|
|
#include <sys/types.h>
|
2014-08-01 14:39:55 -04:00
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
2015-01-15 10:00:43 -08:00
|
|
|
#include "base/format_macros.h"
|
2015-03-13 13:53:38 -04:00
|
|
|
#include "base/scoped_generic.h"
|
2019-01-04 16:57:57 -05:00
|
|
|
#include "base/stl_util.h"
|
2015-01-02 18:46:10 -05:00
|
|
|
#include "base/strings/stringprintf.h"
|
2014-08-01 14:39:55 -04:00
|
|
|
#include "gtest/gtest.h"
|
|
|
|
|
2014-10-07 17:28:50 -04:00
|
|
|
namespace crashpad {
|
|
|
|
namespace test {
|
2014-08-01 14:39:55 -04:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
TEST(UUID, UUID) {
|
|
|
|
UUID uuid_zero;
|
2016-11-10 15:11:20 -05:00
|
|
|
uuid_zero.InitializeToZero();
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
EXPECT_EQ(uuid_zero.data_1, 0u);
|
|
|
|
EXPECT_EQ(uuid_zero.data_2, 0u);
|
|
|
|
EXPECT_EQ(uuid_zero.data_3, 0u);
|
|
|
|
EXPECT_EQ(uuid_zero.data_4[0], 0u);
|
|
|
|
EXPECT_EQ(uuid_zero.data_4[1], 0u);
|
|
|
|
EXPECT_EQ(uuid_zero.data_5[0], 0u);
|
|
|
|
EXPECT_EQ(uuid_zero.data_5[1], 0u);
|
|
|
|
EXPECT_EQ(uuid_zero.data_5[2], 0u);
|
|
|
|
EXPECT_EQ(uuid_zero.data_5[3], 0u);
|
|
|
|
EXPECT_EQ(uuid_zero.data_5[4], 0u);
|
|
|
|
EXPECT_EQ(uuid_zero.data_5[5], 0u);
|
|
|
|
EXPECT_EQ(uuid_zero.ToString(), "00000000-0000-0000-0000-000000000000");
|
2014-08-01 14:39:55 -04:00
|
|
|
|
2017-07-25 13:34:04 -04:00
|
|
|
static constexpr uint8_t kBytes[16] = {0x00,
|
|
|
|
0x01,
|
|
|
|
0x02,
|
|
|
|
0x03,
|
|
|
|
0x04,
|
|
|
|
0x05,
|
|
|
|
0x06,
|
|
|
|
0x07,
|
|
|
|
0x08,
|
|
|
|
0x09,
|
|
|
|
0x0a,
|
|
|
|
0x0b,
|
|
|
|
0x0c,
|
|
|
|
0x0d,
|
|
|
|
0x0e,
|
|
|
|
0x0f};
|
2016-11-10 15:11:20 -05:00
|
|
|
UUID uuid;
|
|
|
|
uuid.InitializeFromBytes(kBytes);
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
EXPECT_EQ(uuid.data_1, 0x00010203u);
|
|
|
|
EXPECT_EQ(uuid.data_2, 0x0405u);
|
|
|
|
EXPECT_EQ(uuid.data_3, 0x0607u);
|
|
|
|
EXPECT_EQ(uuid.data_4[0], 0x08u);
|
|
|
|
EXPECT_EQ(uuid.data_4[1], 0x09u);
|
|
|
|
EXPECT_EQ(uuid.data_5[0], 0x0au);
|
|
|
|
EXPECT_EQ(uuid.data_5[1], 0x0bu);
|
|
|
|
EXPECT_EQ(uuid.data_5[2], 0x0cu);
|
|
|
|
EXPECT_EQ(uuid.data_5[3], 0x0du);
|
|
|
|
EXPECT_EQ(uuid.data_5[4], 0x0eu);
|
|
|
|
EXPECT_EQ(uuid.data_5[5], 0x0fu);
|
|
|
|
EXPECT_EQ(uuid.ToString(), "00010203-0405-0607-0809-0a0b0c0d0e0f");
|
2014-08-01 14:39:55 -04:00
|
|
|
|
2014-09-04 11:45:40 -04:00
|
|
|
// Test both operator== and operator!=.
|
|
|
|
EXPECT_FALSE(uuid == uuid_zero);
|
|
|
|
EXPECT_NE(uuid, uuid_zero);
|
|
|
|
|
2016-11-10 15:11:20 -05:00
|
|
|
UUID uuid_2;
|
|
|
|
uuid_2.InitializeFromBytes(kBytes);
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
EXPECT_EQ(uuid_2, uuid);
|
2014-09-04 11:45:40 -04:00
|
|
|
EXPECT_FALSE(uuid != uuid_2);
|
|
|
|
|
|
|
|
// Make sure that operator== and operator!= check the entire UUID.
|
|
|
|
++uuid.data_1;
|
|
|
|
EXPECT_NE(uuid, uuid_2);
|
|
|
|
--uuid.data_1;
|
|
|
|
++uuid.data_2;
|
|
|
|
EXPECT_NE(uuid, uuid_2);
|
|
|
|
--uuid.data_2;
|
|
|
|
++uuid.data_3;
|
|
|
|
EXPECT_NE(uuid, uuid_2);
|
|
|
|
--uuid.data_3;
|
2019-01-04 16:57:57 -05:00
|
|
|
for (size_t index = 0; index < base::size(uuid.data_4); ++index) {
|
2014-09-04 11:45:40 -04:00
|
|
|
++uuid.data_4[index];
|
|
|
|
EXPECT_NE(uuid, uuid_2);
|
|
|
|
--uuid.data_4[index];
|
|
|
|
}
|
2019-01-04 16:57:57 -05:00
|
|
|
for (size_t index = 0; index < base::size(uuid.data_5); ++index) {
|
2014-09-04 11:45:40 -04:00
|
|
|
++uuid.data_5[index];
|
|
|
|
EXPECT_NE(uuid, uuid_2);
|
|
|
|
--uuid.data_5[index];
|
|
|
|
}
|
|
|
|
|
|
|
|
// Make sure that the UUIDs are equal again, otherwise the test above may not
|
|
|
|
// have been valid.
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
EXPECT_EQ(uuid_2, uuid);
|
2014-09-04 11:45:40 -04:00
|
|
|
|
2017-07-25 13:34:04 -04:00
|
|
|
static constexpr uint8_t kMoreBytes[16] = {0xff,
|
|
|
|
0xee,
|
|
|
|
0xdd,
|
|
|
|
0xcc,
|
|
|
|
0xbb,
|
|
|
|
0xaa,
|
|
|
|
0x99,
|
|
|
|
0x88,
|
|
|
|
0x77,
|
|
|
|
0x66,
|
|
|
|
0x55,
|
|
|
|
0x44,
|
|
|
|
0x33,
|
|
|
|
0x22,
|
|
|
|
0x11,
|
|
|
|
0x00};
|
2014-08-01 16:10:58 -04:00
|
|
|
uuid.InitializeFromBytes(kMoreBytes);
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
EXPECT_EQ(uuid.data_1, 0xffeeddccu);
|
|
|
|
EXPECT_EQ(uuid.data_2, 0xbbaau);
|
|
|
|
EXPECT_EQ(uuid.data_3, 0x9988u);
|
|
|
|
EXPECT_EQ(uuid.data_4[0], 0x77u);
|
|
|
|
EXPECT_EQ(uuid.data_4[1], 0x66u);
|
|
|
|
EXPECT_EQ(uuid.data_5[0], 0x55u);
|
|
|
|
EXPECT_EQ(uuid.data_5[1], 0x44u);
|
|
|
|
EXPECT_EQ(uuid.data_5[2], 0x33u);
|
|
|
|
EXPECT_EQ(uuid.data_5[3], 0x22u);
|
|
|
|
EXPECT_EQ(uuid.data_5[4], 0x11u);
|
|
|
|
EXPECT_EQ(uuid.data_5[5], 0x00u);
|
|
|
|
EXPECT_EQ(uuid.ToString(), "ffeeddcc-bbaa-9988-7766-554433221100");
|
2014-08-03 18:50:09 -04:00
|
|
|
|
2014-09-04 11:45:40 -04:00
|
|
|
EXPECT_NE(uuid, uuid_2);
|
|
|
|
EXPECT_NE(uuid, uuid_zero);
|
|
|
|
|
2014-08-03 18:50:09 -04:00
|
|
|
// Test that UUID is standard layout.
|
|
|
|
memset(&uuid, 0x45, 16);
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
EXPECT_EQ(uuid.data_1, 0x45454545u);
|
|
|
|
EXPECT_EQ(uuid.data_2, 0x4545u);
|
|
|
|
EXPECT_EQ(uuid.data_3, 0x4545u);
|
|
|
|
EXPECT_EQ(uuid.data_4[0], 0x45u);
|
|
|
|
EXPECT_EQ(uuid.data_4[1], 0x45u);
|
|
|
|
EXPECT_EQ(uuid.data_5[0], 0x45u);
|
|
|
|
EXPECT_EQ(uuid.data_5[1], 0x45u);
|
|
|
|
EXPECT_EQ(uuid.data_5[2], 0x45u);
|
|
|
|
EXPECT_EQ(uuid.data_5[3], 0x45u);
|
|
|
|
EXPECT_EQ(uuid.data_5[4], 0x45u);
|
|
|
|
EXPECT_EQ(uuid.data_5[5], 0x45u);
|
|
|
|
EXPECT_EQ(uuid.ToString(), "45454545-4545-4545-4545-454545454545");
|
2015-04-20 14:21:48 -07:00
|
|
|
|
2016-11-10 15:11:20 -05:00
|
|
|
UUID initialized_generated;
|
|
|
|
initialized_generated.InitializeWithNew();
|
2015-04-20 14:21:48 -07:00
|
|
|
EXPECT_NE(initialized_generated, uuid_zero);
|
2014-08-01 14:39:55 -04:00
|
|
|
}
|
|
|
|
|
2015-01-02 18:46:10 -05:00
|
|
|
TEST(UUID, FromString) {
|
2017-07-25 13:34:04 -04:00
|
|
|
static constexpr struct TestCase {
|
2015-01-02 18:46:10 -05:00
|
|
|
const char* uuid_string;
|
|
|
|
bool success;
|
|
|
|
} kCases[] = {
|
|
|
|
// Valid:
|
|
|
|
{"c6849cb5-fe14-4a79-8978-9ae6034c521d", true},
|
|
|
|
{"00000000-0000-0000-0000-000000000000", true},
|
|
|
|
{"ffffffff-ffff-ffff-ffff-ffffffffffff", true},
|
|
|
|
// Outside HEX range:
|
|
|
|
{"7318z10b-c453-4cef-9dc8-015655cb4bbc", false},
|
|
|
|
{"7318a10b-c453-4cef-9dz8-015655cb4bbc", false},
|
|
|
|
// Incomplete:
|
|
|
|
{"15655cb4-", false},
|
|
|
|
{"7318f10b-c453-4cef-9dc8-015655cb4bb", false},
|
|
|
|
{"318f10b-c453-4cef-9dc8-015655cb4bb2", false},
|
|
|
|
{"7318f10b-c453-4ef-9dc8-015655cb4bb2", false},
|
|
|
|
{"", false},
|
|
|
|
{"abcd", false},
|
|
|
|
// Trailing data:
|
|
|
|
{"6d247a34-53d5-40ec-a90d-d8dea9e94cc01", false}
|
|
|
|
};
|
|
|
|
|
2016-11-10 15:11:20 -05:00
|
|
|
UUID uuid_zero;
|
|
|
|
uuid_zero.InitializeToZero();
|
|
|
|
const std::string empty_uuid = uuid_zero.ToString();
|
2015-01-02 18:46:10 -05:00
|
|
|
|
2019-01-04 16:57:57 -05:00
|
|
|
for (size_t index = 0; index < base::size(kCases); ++index) {
|
2015-01-02 18:46:10 -05:00
|
|
|
const TestCase& test_case = kCases[index];
|
2015-01-15 10:00:43 -08:00
|
|
|
SCOPED_TRACE(base::StringPrintf(
|
|
|
|
"index %" PRIuS ": %s", index, test_case.uuid_string));
|
2015-01-02 18:46:10 -05:00
|
|
|
|
|
|
|
UUID uuid;
|
2016-11-10 15:11:20 -05:00
|
|
|
uuid.InitializeToZero();
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
EXPECT_EQ(uuid.InitializeFromString(test_case.uuid_string),
|
|
|
|
test_case.success);
|
2015-01-02 18:46:10 -05:00
|
|
|
if (test_case.success) {
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
EXPECT_EQ(uuid.ToString(), test_case.uuid_string);
|
2015-01-02 18:46:10 -05:00
|
|
|
} else {
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
EXPECT_EQ(uuid.ToString(), empty_uuid);
|
2015-01-02 18:46:10 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Test for case insensitivty.
|
|
|
|
UUID uuid;
|
|
|
|
uuid.InitializeFromString("F32E5BDC-2681-4C73-A4E6-911FFD89B846");
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
EXPECT_EQ(uuid.ToString(), "f32e5bdc-2681-4c73-a4e6-911ffd89b846");
|
2015-01-02 18:46:10 -05:00
|
|
|
|
|
|
|
// Mixed case.
|
|
|
|
uuid.InitializeFromString("5762C15D-50b5-4171-a2e9-7429C9EC6CAB");
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
EXPECT_EQ(uuid.ToString(), "5762c15d-50b5-4171-a2e9-7429c9ec6cab");
|
2018-02-13 12:09:33 -08:00
|
|
|
|
|
|
|
// Test accepting a StringPiece16.
|
|
|
|
// clang-format off
|
|
|
|
static constexpr base::char16 kChar16UUID[] = {
|
|
|
|
'f', '3', '2', 'e', '5', 'b', 'd', 'c', '-',
|
|
|
|
'2', '6', '8', '1', '-',
|
|
|
|
'4', 'c', '7', '3', '-',
|
|
|
|
'a', '4', 'e', '6', '-',
|
|
|
|
'3', '3', '3', 'f', 'f', 'd', '3', '3', 'b', '3', '3', '3',
|
|
|
|
};
|
|
|
|
// clang-format on
|
|
|
|
EXPECT_TRUE(uuid.InitializeFromString(
|
2019-01-04 16:57:57 -05:00
|
|
|
base::StringPiece16(kChar16UUID, base::size(kChar16UUID))));
|
2018-02-13 12:09:33 -08:00
|
|
|
EXPECT_EQ(uuid.ToString(), "f32e5bdc-2681-4c73-a4e6-333ffd33b333");
|
|
|
|
|
|
|
|
#if defined(OS_WIN)
|
|
|
|
// Test accepting a StringPiece16 via L"" literals on Windows.
|
|
|
|
EXPECT_TRUE(
|
|
|
|
uuid.InitializeFromString(L"F32E5BDC-2681-4C73-A4E6-444FFD44B444"));
|
|
|
|
EXPECT_EQ(uuid.ToString(), "f32e5bdc-2681-4c73-a4e6-444ffd44b444");
|
|
|
|
|
|
|
|
EXPECT_TRUE(
|
|
|
|
uuid.InitializeFromString(L"5762C15D-50b5-4171-a2e9-5555C5EC5CAB"));
|
|
|
|
EXPECT_EQ(uuid.ToString(), "5762c15d-50b5-4171-a2e9-5555c5ec5cab");
|
|
|
|
#endif // OS_WIN
|
2015-01-02 18:46:10 -05:00
|
|
|
}
|
|
|
|
|
2015-03-13 13:53:38 -04:00
|
|
|
#if defined(OS_WIN)
|
|
|
|
|
|
|
|
TEST(UUID, FromSystem) {
|
|
|
|
::GUID system_uuid;
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
ASSERT_EQ(UuidCreate(&system_uuid), RPC_S_OK);
|
2015-03-13 13:53:38 -04:00
|
|
|
|
|
|
|
UUID uuid;
|
|
|
|
uuid.InitializeFromSystemUUID(&system_uuid);
|
|
|
|
|
|
|
|
RPC_WSTR system_string;
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
ASSERT_EQ(UuidToString(&system_uuid, &system_string), RPC_S_OK);
|
2015-03-13 13:53:38 -04:00
|
|
|
|
|
|
|
struct ScopedRpcStringFreeTraits {
|
|
|
|
static RPC_WSTR* InvalidValue() { return nullptr; }
|
|
|
|
static void Free(RPC_WSTR* rpc_string) {
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
EXPECT_EQ(RpcStringFree(rpc_string), RPC_S_OK);
|
2015-03-13 13:53:38 -04:00
|
|
|
}
|
|
|
|
};
|
|
|
|
using ScopedRpcString =
|
|
|
|
base::ScopedGeneric<RPC_WSTR*, ScopedRpcStringFreeTraits>;
|
|
|
|
ScopedRpcString scoped_system_string(&system_string);
|
|
|
|
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
EXPECT_EQ(uuid.ToString16(), reinterpret_cast<wchar_t*>(system_string));
|
2015-03-13 13:53:38 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif // OS_WIN
|
|
|
|
|
2014-08-01 14:39:55 -04:00
|
|
|
} // namespace
|
2014-10-07 17:28:50 -04:00
|
|
|
} // namespace test
|
|
|
|
} // namespace crashpad
|