Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(653)

Side by Side Diff: experimental/visual_studio_plugin/src/NaClVsx.Package/NaClVsx.Package_UnitTestProject/DebugInfoEntryTest.cs

Issue 10928195: First round of dead file removal (Closed) Base URL: https://github.com/samclegg/nativeclient-sdk.git@master
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Native Client Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #region
6
7 using Google.NaClVsx.DebugSupport.DWARF;
8 using Microsoft.VisualStudio.TestTools.UnitTesting;
9
10 #endregion
11
12 namespace NaClVsx.Package_UnitTestProject {
13 /// <summary>
14 /// This is a test class for DebugInfoEntryTest and is intended
15 /// to contain all DebugInfoEntryTest Unit Tests
16 /// </summary>
17 [TestClass]
18 public class DebugInfoEntryTest {
19 /// <summary>
20 /// Adds a few RangeList entries to a DIE.
21 /// </summary>
22 [TestMethod]
23 public void AddRangeListEntryByAddressTest() {
24 var target = new DebugInfoEntry();
25 var rangeListEntry1 = new RangeListEntry();
26 var rangeListEntry2 = new RangeListEntry();
27 var redundantRangeListEntry = new RangeListEntry();
28 target.AddRangeListEntryByAddress(1234, rangeListEntry1);
29 target.AddRangeListEntryByAddress(4567, rangeListEntry2);
30 target.AddRangeListEntryByAddress(1234, redundantRangeListEntry);
31 Assert.AreEqual(2, target.RangeListsByAddress.Count);
32 }
33
34 /// <summary>
35 /// A test for GetLowPC
36 /// </summary>
37 [TestMethod]
38 public void GetLowPCTest() {
39 var target = new DebugInfoEntry();
40 ulong expected = 0;
41 Assert.AreEqual(expected, target.GetLowPC());
42 expected = 123456;
43 target.Attributes.Add(DwarfAttribute.DW_AT_low_pc, expected);
44 Assert.AreEqual(expected, target.GetLowPC());
45 }
46
47 /// <summary>
48 /// A test for GetFrameBase
49 /// </summary>
50 [TestMethod]
51 public void GetFrameBaseTest() {
52 var target = new DebugInfoEntry();
53 ulong expected = 0;
54 Assert.AreEqual(expected, target.GetFrameBase());
55 expected = 123456;
56 target.Attributes.Add(DwarfAttribute.DW_AT_frame_base, expected);
57 Assert.AreEqual(expected, target.GetFrameBase());
58 }
59
60 /// <summary>
61 /// A test for DebugInfoEntry Constructor
62 /// </summary>
63 [TestMethod]
64 public void DebugInfoEntryConstructorTest() {
65 var target = new DebugInfoEntry();
66 Assert.IsNotNull(target);
67 }
68
69 /// <summary>
70 /// A test for GetNearestAncestorWithTag
71 /// </summary>
72 [TestMethod]
73 public void GetNearestAncestorWithTagTest() {
74 var target = new DebugInfoEntry();
75 DebugInfoEntry expected = null;
76 Assert.AreEqual(
77 expected,
78 target.GetNearestAncestorWithTag(DwarfTag.DW_TAG_subprogram));
79 target.Tag = DwarfTag.DW_TAG_subprogram;
80 expected = target;
81 Assert.AreEqual(
82 expected,
83 target.GetNearestAncestorWithTag(DwarfTag.DW_TAG_subprogram));
84 target.Tag = DwarfTag.DW_TAG_namelist_item;
85 expected = new DebugInfoEntry();
86 expected.Tag = DwarfTag.DW_TAG_subprogram;
87 target.OuterScope = expected;
88 Assert.AreEqual(
89 expected,
90 target.GetNearestAncestorWithTag(DwarfTag.DW_TAG_subprogram));
91 }
92
93 /// <summary>
94 /// A test for HasAttribute. Checks both "true" and "false" cases.
95 /// </summary>
96 [TestMethod]
97 public void HasAttributeTest() {
98 var target = new DebugInfoEntry();
99 const DwarfAttribute kAttribute = DwarfAttribute.DW_AT_ranges;
100 Assert.IsFalse(target.HasAttribute(kAttribute));
101 target.Attributes.Add(DwarfAttribute.DW_AT_ranges, 0);
102 Assert.IsTrue(target.HasAttribute(kAttribute));
103 }
104
105 /// <summary>
106 /// A test for HasAsAncestor. Checks the case where the ancestor does not exist, the case
107 /// where the ancestor is a direct parent, and the case where the ancestor is more distant.
108 /// </summary>
109 [TestMethod]
110 public void HasAsAncestorTest() {
111 var target = new DebugInfoEntry();
112 const ulong kAncestorKey = 123456;
113 Assert.IsFalse(target.HasAsAncestor(kAncestorKey));
114 var ancestor = new DebugInfoEntry();
115 ancestor.Key = kAncestorKey;
116 target.ParentKey = kAncestorKey;
117 target.OuterScope = ancestor;
118 Assert.IsTrue(target.HasAsAncestor(kAncestorKey));
119 var parent = new DebugInfoEntry();
120 parent.OuterScope = ancestor;
121 parent.ParentKey = kAncestorKey;
122 target.OuterScope = parent;
123 Assert.IsTrue(target.HasAsAncestor(kAncestorKey));
124 }
125
126 /// <summary>
127 /// A test for GetRangesOffset
128 /// </summary>
129 [TestMethod]
130 public void GetRangesOffsetTest() {
131 var target = new DebugInfoEntry();
132 Assert.AreEqual(ulong.MaxValue, target.GetRangesOffset());
133 const ulong kRangesOffset = 123456;
134 target.Attributes.Add(DwarfAttribute.DW_AT_ranges, kRangesOffset);
135 Assert.AreEqual(kRangesOffset, target.GetRangesOffset());
136 }
137 }
138 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698