[M108 Migration][HBBTV] Implement ewk_context_register_jsplugin_mime_types API
[platform/framework/web/chromium-efl.git] / courgette / typedrva_unittest.cc
1 // Copyright 2013 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include <stdint.h>
6
7 #include "courgette/base_test_unittest.h"
8 #include "courgette/disassembler_elf_32_x86.h"
9 #include "courgette/image_utils.h"
10
11 class TypedRVATest : public BaseTest {
12  public:
13   void TestRelativeTargetX86(courgette::RVA word, courgette::RVA expected)
14     const;
15
16 };
17
18 void TypedRVATest::TestRelativeTargetX86(courgette::RVA word,
19                                          courgette::RVA expected) const {
20   courgette::DisassemblerElf32X86::TypedRVAX86* typed_rva
21     = new courgette::DisassemblerElf32X86::TypedRVAX86(0);
22   const uint8_t* op_pointer = reinterpret_cast<const uint8_t*>(&word);
23
24   EXPECT_TRUE(typed_rva->ComputeRelativeTarget(op_pointer));
25   EXPECT_EQ(typed_rva->relative_target(), expected);
26
27   delete typed_rva;
28 }
29
30 uint32_t Read32LittleEndian(const void* address) {
31   return *reinterpret_cast<const uint32_t*>(address);
32 }
33
34 TEST_F(TypedRVATest, TestX86) {
35   TestRelativeTargetX86(0x0, 0x4);
36 }