OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/eh-frame.h" | 5 #include "src/eh-frame.h" |
6 #include "testing/gtest/include/gtest/gtest.h" | 6 #include "testing/gtest/include/gtest/gtest.h" |
7 | 7 |
8 // Test enabled only on supported architectures. | 8 // Test enabled only on supported architectures. |
9 #if defined(V8_TARGET_ARCH_X64) || defined(V8_TARGET_ARCH_ARM) || \ | 9 #if defined(V8_TARGET_ARCH_X64) || defined(V8_TARGET_ARCH_ARM) || \ |
10 defined(V8_TARGET_ARCH_ARM64) | 10 defined(V8_TARGET_ARCH_ARM64) |
(...skipping 22 matching lines...) Expand all Loading... |
33 iterator.Skip(2); | 33 iterator.Skip(2); |
34 EXPECT_EQ(2, iterator.GetCurrentOffset()); | 34 EXPECT_EQ(2, iterator.GetCurrentOffset()); |
35 EXPECT_EQ(0xc0, iterator.GetNextByte()); | 35 EXPECT_EQ(0xc0, iterator.GetNextByte()); |
36 iterator.Skip(1); | 36 iterator.Skip(1); |
37 EXPECT_TRUE(iterator.Done()); | 37 EXPECT_TRUE(iterator.Done()); |
38 } | 38 } |
39 | 39 |
40 TEST_F(EhFrameIteratorTest, ULEB128Decoding) { | 40 TEST_F(EhFrameIteratorTest, ULEB128Decoding) { |
41 static const byte kEncoded[] = {0xe5, 0x8e, 0x26}; | 41 static const byte kEncoded[] = {0xe5, 0x8e, 0x26}; |
42 EhFrameIterator iterator(&kEncoded[0], &kEncoded[0] + sizeof(kEncoded)); | 42 EhFrameIterator iterator(&kEncoded[0], &kEncoded[0] + sizeof(kEncoded)); |
43 EXPECT_EQ(624485, iterator.GetNextULeb128()); | 43 EXPECT_EQ(624485u, iterator.GetNextULeb128()); |
44 EXPECT_TRUE(iterator.Done()); | 44 EXPECT_TRUE(iterator.Done()); |
45 } | 45 } |
46 | 46 |
47 TEST_F(EhFrameIteratorTest, SLEB128DecodingPositive) { | 47 TEST_F(EhFrameIteratorTest, SLEB128DecodingPositive) { |
48 static const byte kEncoded[] = {0xe5, 0x8e, 0x26}; | 48 static const byte kEncoded[] = {0xe5, 0x8e, 0x26}; |
49 EhFrameIterator iterator(&kEncoded[0], &kEncoded[0] + sizeof(kEncoded)); | 49 EhFrameIterator iterator(&kEncoded[0], &kEncoded[0] + sizeof(kEncoded)); |
50 EXPECT_EQ(624485, iterator.GetNextSLeb128()); | 50 EXPECT_EQ(624485, iterator.GetNextSLeb128()); |
51 EXPECT_TRUE(iterator.Done()); | 51 EXPECT_TRUE(iterator.Done()); |
52 } | 52 } |
53 | 53 |
54 TEST_F(EhFrameIteratorTest, SLEB128DecodingNegative) { | 54 TEST_F(EhFrameIteratorTest, SLEB128DecodingNegative) { |
55 static const byte kEncoded[] = {0x9b, 0xf1, 0x59}; | 55 static const byte kEncoded[] = {0x9b, 0xf1, 0x59}; |
56 EhFrameIterator iterator(&kEncoded[0], &kEncoded[0] + sizeof(kEncoded)); | 56 EhFrameIterator iterator(&kEncoded[0], &kEncoded[0] + sizeof(kEncoded)); |
57 EXPECT_EQ(-624485, iterator.GetNextSLeb128()); | 57 EXPECT_EQ(-624485, iterator.GetNextSLeb128()); |
58 EXPECT_TRUE(iterator.Done()); | 58 EXPECT_TRUE(iterator.Done()); |
59 } | 59 } |
60 | 60 |
61 #endif | 61 #endif |
OLD | NEW |