Index: test/unittests/eh-frame-iterator-unittest.cc |
diff --git a/test/unittests/eh-frame-iterator-unittest.cc b/test/unittests/eh-frame-iterator-unittest.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..c5c6ded18ae9e497fcf9fc0bf6696cb1e492f4e3 |
--- /dev/null |
+++ b/test/unittests/eh-frame-iterator-unittest.cc |
@@ -0,0 +1,55 @@ |
+// 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" |
+ |
+// Test enabled only on supported architectures. |
+#if defined(V8_TARGET_ARCH_X64) || defined(V8_TARGET_ARCH_ARM) || \ |
+ defined(V8_TARGET_ARCH_ARM64) |
+ |
+using namespace v8::internal; |
+ |
+namespace v8 { |
+namespace internal { |
+ |
+class EhFrameIteratorTest : public testing::Test { |
+ protected: |
+ static uint32_t DecodeULEB128(const byte* encoded, int* encoded_size) { |
+ return EhFrameIterator::DecodeULEB128(encoded, encoded_size); |
+ } |
+ |
+ static int32_t DecodeSLEB128(const byte* encoded, int* encoded_size) { |
+ return EhFrameIterator::DecodeSLEB128(encoded, encoded_size); |
+ } |
+}; |
+ |
+} // namespace internal |
+} // namespace v8 |
+ |
+TEST_F(EhFrameIteratorTest, ULEB128Decoding) { |
+ static const byte kEncoded[] = {0xe5, 0x8e, 0x26}; |
+ int size = 0; |
+ uint32_t value = DecodeULEB128(kEncoded, &size); |
+ EXPECT_EQ(static_cast<int>(sizeof(kEncoded)), size); |
+ EXPECT_EQ(624485, value); |
+} |
+ |
+TEST_F(EhFrameIteratorTest, SLEB128DecodingPositive) { |
+ static const byte kEncoded[] = {0xe5, 0x8e, 0x26}; |
+ int size = 0; |
+ int32_t value = DecodeSLEB128(kEncoded, &size); |
+ EXPECT_EQ(static_cast<int>(sizeof(kEncoded)), size); |
+ EXPECT_EQ(624485, value); |
+} |
+ |
+TEST_F(EhFrameIteratorTest, SLEB128DecodingNegative) { |
+ static const byte kEncoded[] = {0x9b, 0xf1, 0x59}; |
+ int size = 0; |
+ int32_t value = DecodeSLEB128(kEncoded, &size); |
+ EXPECT_EQ(static_cast<int>(sizeof(kEncoded)), size); |
+ EXPECT_EQ(-624485, value); |
+} |
+ |
+#endif |