mirror of
https://github.com/chromium/crashpad.git
synced 2024-12-26 23:01:05 +08:00
4b450c8137
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
77d6b17338
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>
106 lines
3.1 KiB
C++
106 lines
3.1 KiB
C++
// 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 "minidump/minidump_rva_list_writer.h"
|
|
|
|
#include <utility>
|
|
|
|
#include "base/format_macros.h"
|
|
#include "base/memory/ptr_util.h"
|
|
#include "base/strings/stringprintf.h"
|
|
#include "gtest/gtest.h"
|
|
#include "minidump/test/minidump_rva_list_test_util.h"
|
|
#include "minidump/test/minidump_writable_test_util.h"
|
|
#include "util/file/string_file.h"
|
|
|
|
namespace crashpad {
|
|
namespace test {
|
|
namespace {
|
|
|
|
class TestMinidumpRVAListWriter final : public internal::MinidumpRVAListWriter {
|
|
public:
|
|
TestMinidumpRVAListWriter() : MinidumpRVAListWriter() {}
|
|
~TestMinidumpRVAListWriter() override {}
|
|
|
|
void AddChild(uint32_t value) {
|
|
auto child = base::WrapUnique(new TestUInt32MinidumpWritable(value));
|
|
MinidumpRVAListWriter::AddChild(std::move(child));
|
|
}
|
|
|
|
private:
|
|
DISALLOW_COPY_AND_ASSIGN(TestMinidumpRVAListWriter);
|
|
};
|
|
|
|
TEST(MinidumpRVAListWriter, Empty) {
|
|
TestMinidumpRVAListWriter list_writer;
|
|
|
|
StringFile string_file;
|
|
|
|
ASSERT_TRUE(list_writer.WriteEverything(&string_file));
|
|
EXPECT_EQ(string_file.string().size(), sizeof(MinidumpRVAList));
|
|
|
|
const MinidumpRVAList* list = MinidumpRVAListAtStart(string_file.string(), 0);
|
|
ASSERT_TRUE(list);
|
|
}
|
|
|
|
TEST(MinidumpRVAListWriter, OneChild) {
|
|
TestMinidumpRVAListWriter list_writer;
|
|
|
|
const uint32_t kValue = 0;
|
|
list_writer.AddChild(kValue);
|
|
|
|
StringFile string_file;
|
|
|
|
ASSERT_TRUE(list_writer.WriteEverything(&string_file));
|
|
|
|
const MinidumpRVAList* list = MinidumpRVAListAtStart(string_file.string(), 1);
|
|
ASSERT_TRUE(list);
|
|
|
|
const uint32_t* child = MinidumpWritableAtRVA<uint32_t>(
|
|
string_file.string(), list->children[0]);
|
|
ASSERT_TRUE(child);
|
|
EXPECT_EQ(*child, kValue);
|
|
}
|
|
|
|
TEST(MinidumpRVAListWriter, ThreeChildren) {
|
|
TestMinidumpRVAListWriter list_writer;
|
|
|
|
const uint32_t kValues[] = { 0x80000000, 0x55555555, 0x66006600 };
|
|
|
|
list_writer.AddChild(kValues[0]);
|
|
list_writer.AddChild(kValues[1]);
|
|
list_writer.AddChild(kValues[2]);
|
|
|
|
StringFile string_file;
|
|
|
|
ASSERT_TRUE(list_writer.WriteEverything(&string_file));
|
|
|
|
const MinidumpRVAList* list =
|
|
MinidumpRVAListAtStart(string_file.string(), arraysize(kValues));
|
|
ASSERT_TRUE(list);
|
|
|
|
for (size_t index = 0; index < arraysize(kValues); ++index) {
|
|
SCOPED_TRACE(base::StringPrintf("index %" PRIuS, index));
|
|
|
|
const uint32_t* child = MinidumpWritableAtRVA<uint32_t>(
|
|
string_file.string(), list->children[index]);
|
|
ASSERT_TRUE(child);
|
|
EXPECT_EQ(*child, kValues[index]);
|
|
}
|
|
}
|
|
|
|
} // namespace
|
|
} // namespace test
|
|
} // namespace crashpad
|