822be9b238
This patch normalizes the casing of hexadecimal digits in escape sequences of the form `\xNN` and integer literals of the form `0xNNNN`. Previously, the V8 code base used an inconsistent mixture of uppercase and lowercase. Google’s C++ style guide uses uppercase in its examples: https://google.github.io/styleguide/cppguide.html#Non-ASCII_Characters Moreover, uppercase letters more clearly stand out from the lowercase `x` (or `u`) characters at the start, as well as lowercase letters elsewhere in strings. BUG=v8:7109 TBR=marja@chromium.org,titzer@chromium.org,mtrofin@chromium.org,mstarzinger@chromium.org,rossberg@chromium.org,yangguo@chromium.org,mlippautz@chromium.org NOPRESUBMIT=true Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel;master.tryserver.chromium.linux:linux_chromium_rel_ng Change-Id: I790e21c25d96ad5d95c8229724eb45d2aa9e22d6 Reviewed-on: https://chromium-review.googlesource.com/804294 Commit-Queue: Mathias Bynens <mathias@chromium.org> Reviewed-by: Jakob Kummerow <jkummerow@chromium.org> Cr-Commit-Position: refs/heads/master@{#49810}
66 lines
2.0 KiB
C++
66 lines
2.0 KiB
C++
// Copyright 2016 the V8 project authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#include "src/eh-frame.h"
|
|
#include "testing/gtest/include/gtest/gtest.h"
|
|
|
|
namespace v8 {
|
|
namespace internal {
|
|
|
|
// Test enabled only on supported architectures.
|
|
#if defined(V8_TARGET_ARCH_X64) || defined(V8_TARGET_ARCH_ARM) || \
|
|
defined(V8_TARGET_ARCH_ARM64)
|
|
|
|
namespace {
|
|
|
|
class EhFrameIteratorTest : public testing::Test {};
|
|
|
|
} // namespace
|
|
|
|
TEST_F(EhFrameIteratorTest, Values) {
|
|
// Assuming little endian.
|
|
static const byte kEncoded[] = {0xDE, 0xC0, 0xAD, 0xDE, 0xEF, 0xBE, 0xFF};
|
|
EhFrameIterator iterator(&kEncoded[0], &kEncoded[0] + sizeof(kEncoded));
|
|
EXPECT_EQ(0xDEADC0DE, iterator.GetNextUInt32());
|
|
EXPECT_EQ(0xBEEF, iterator.GetNextUInt16());
|
|
EXPECT_EQ(0xFF, iterator.GetNextByte());
|
|
EXPECT_TRUE(iterator.Done());
|
|
}
|
|
|
|
TEST_F(EhFrameIteratorTest, Skip) {
|
|
static const byte kEncoded[] = {0xDE, 0xAD, 0xC0, 0xDE};
|
|
EhFrameIterator iterator(&kEncoded[0], &kEncoded[0] + sizeof(kEncoded));
|
|
iterator.Skip(2);
|
|
EXPECT_EQ(2, iterator.GetCurrentOffset());
|
|
EXPECT_EQ(0xC0, iterator.GetNextByte());
|
|
iterator.Skip(1);
|
|
EXPECT_TRUE(iterator.Done());
|
|
}
|
|
|
|
TEST_F(EhFrameIteratorTest, ULEB128Decoding) {
|
|
static const byte kEncoded[] = {0xE5, 0x8E, 0x26};
|
|
EhFrameIterator iterator(&kEncoded[0], &kEncoded[0] + sizeof(kEncoded));
|
|
EXPECT_EQ(624485u, iterator.GetNextULeb128());
|
|
EXPECT_TRUE(iterator.Done());
|
|
}
|
|
|
|
TEST_F(EhFrameIteratorTest, SLEB128DecodingPositive) {
|
|
static const byte kEncoded[] = {0xE5, 0x8E, 0x26};
|
|
EhFrameIterator iterator(&kEncoded[0], &kEncoded[0] + sizeof(kEncoded));
|
|
EXPECT_EQ(624485, iterator.GetNextSLeb128());
|
|
EXPECT_TRUE(iterator.Done());
|
|
}
|
|
|
|
TEST_F(EhFrameIteratorTest, SLEB128DecodingNegative) {
|
|
static const byte kEncoded[] = {0x9B, 0xF1, 0x59};
|
|
EhFrameIterator iterator(&kEncoded[0], &kEncoded[0] + sizeof(kEncoded));
|
|
EXPECT_EQ(-624485, iterator.GetNextSLeb128());
|
|
EXPECT_TRUE(iterator.Done());
|
|
}
|
|
|
|
#endif
|
|
|
|
} // namespace internal
|
|
} // namespace v8
|