-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProblem2.cs
150 lines (143 loc) · 4.31 KB
/
Problem2.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
using Problems.Solutions;
namespace Problems.Tests.Tests;
public class Problem2Tests
{
[Theory]
[MemberData(nameof(GetData))]
public void Test1(Problem2.ListNode l1, Problem2.ListNode l2, Problem2.ListNode expected)
{
// Arrange
var sut = new Problem2();
// Act
var actual = sut.AddTwoNumbers(l1, l2);
// Assert
Assert.Equal(expected, actual, new Problem2.ListNodeComparer());
}
public static IEnumerable<Object[]> GetData()
{
yield return new Object[]
{
new Problem2.ListNode
{
val = 2,
next = new Problem2.ListNode
{
val = 4,
next = new Problem2.ListNode
{
val = 3
}
}
},
new Problem2.ListNode
{
val = 5,
next = new Problem2.ListNode
{
val = 6,
next = new Problem2.ListNode
{
val = 4
}
}
},
new Problem2.ListNode
{
val = 7,
next = new Problem2.ListNode
{
val = 0,
next = new Problem2.ListNode
{
val = 8
}
}
}
};
yield return new Object[]
{
new Problem2.ListNode(0),
new Problem2.ListNode(0),
new Problem2.ListNode(0)
};
yield return new Object[]
{
new Problem2.ListNode
{
val = 9,
next = new Problem2.ListNode
{
val = 9,
next = new Problem2.ListNode
{
val = 9,
next = new Problem2.ListNode
{
val = 9,
next = new Problem2.ListNode
{
val = 9,
next = new Problem2.ListNode
{
val = 9,
next = new Problem2.ListNode
{
val = 9,
}
}
}
}
}
}
},
new Problem2.ListNode
{
val = 9,
next = new Problem2.ListNode
{
val = 9,
next = new Problem2.ListNode
{
val = 9,
next = new Problem2.ListNode
{
val = 9
}
}
}
},
new Problem2.ListNode
{
val = 8,
next = new Problem2.ListNode
{
val = 9,
next = new Problem2.ListNode
{
val = 9,
next = new Problem2.ListNode
{
val = 9,
next = new Problem2.ListNode
{
val = 0,
next = new Problem2.ListNode
{
val = 0,
next = new Problem2.ListNode
{
val = 0,
next = new Problem2.ListNode
{
val = 1,
}
}
}
}
}
}
}
}
};
}
}