Skip to content

Commit 16e9fee

Browse files
Merge remote-tracking branch 'upstream/master'
2 parents e54e114 + d1f4217 commit 16e9fee

File tree

9 files changed

+42
-40
lines changed

9 files changed

+42
-40
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,3 +190,6 @@ _Pvt_Extensions/
190190
ModelManifest.xml
191191
.vs/
192192
.idea/
193+
194+
# Local test runner
195+
testrunner

.travis.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
language: csharp
2-
solution: C-Sharp-Algorithms.sln
3-
dotnet: 2.0.3
42
mono: none
5-
dist: trusty
3+
dotnet: 2.1.502
4+
solution: C-Sharp-Algorithms.sln
65
install:
76
- dotnet restore
7+
# - nuget install xunit.runners -Version 2.0.0 -OutputDirectory testrunner
8+
# - nuget install xunit.runner.console -Version 2.4.1 -OutputDirectory testrunner
89
script:
9-
- dotnet build
10-
- dotnet test UnitTest/UnitTest.csproj
10+
- dotnet msbuild /p:Configuration=Release C-Sharp-Algorithms.sln
11+
# - dotnet restore
12+
# - dotnet test UnitTest/UnitTest.csproj

Algorithms/Algorithms.csproj

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@
33
<TargetFramework>netcoreapp2.0</TargetFramework>
44
</PropertyGroup>
55

6-
<ItemGroup>
7-
<PackageReference Include="xunit" Version="2.4.0" />
8-
</ItemGroup>
9-
106
<ItemGroup>
117
<ProjectReference Include="..\DataStructures\DataStructures.csproj" />
128
</ItemGroup>

Algorithms/Graphs/BellmanFordShortestPaths.cs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,21 +35,23 @@ public class BellmanFordShortestPaths<TGraph, TVertex>
3535
/// </summary>
3636
public BellmanFordShortestPaths(TGraph Graph, TVertex Source)
3737
{
38-
if (Graph == null)
39-
throw new ArgumentNullException();
40-
if (!Graph.HasVertex(Source))
41-
throw new ArgumentException("The source vertex doesn't belong to graph.");
38+
if (Graph == null) {
39+
throw new ArgumentNullException ();
40+
} else {
41+
if (!Graph.HasVertex (Source))
42+
throw new ArgumentException ("The source vertex doesn't belong to graph.");
4243

43-
// Init
44-
_initializeDataMembers(Graph);
44+
// Init
45+
_initializeDataMembers (Graph);
4546

46-
// Traverse the graph
47-
var status = _bellmanFord(Graph, Source);
47+
// Traverse the graph
48+
var status = _bellmanFord (Graph, Source);
4849

49-
if (status == false)
50-
throw new Exception("Negative-weight cycle detected.");
50+
if (status == false)
51+
throw new Exception ("Negative-weight cycle detected.");
5152

52-
Debug.Assert(_checkOptimalityConditions(Graph, Source));
53+
Debug.Assert (_checkOptimalityConditions (Graph, Source));
54+
}
5355
}
5456

5557

DataStructures/DataStructures.csproj

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@
33
<TargetFramework>netcoreapp2.0</TargetFramework>
44
</PropertyGroup>
55

6-
<ItemGroup>
7-
<PackageReference Include="xunit" Version="2.4.0" />
8-
</ItemGroup>
9-
106
<ItemGroup>
117
<Content Include="Data\PrimesDocument_10K.csv">
128
<CopyToOutputDirectory>Always</CopyToOutputDirectory>

UnitTest/DataStructuresTests/AVLTreeTest.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,11 @@ public static void DoTest()
118118
//
119119
/**************************************************************************
120120
** UNBALANCED ===> TRANSITION (1st R) ===> BALANCED (2nd Rt)
121-
** null .6..
121+
** null .5..
122122
** / \ / \
123-
** 2 6 ===> ===> 2 7
124-
** / \ / \ / \ /
125-
** 1 3 5 7 1 3 5
123+
** 2 6 ===> ===> 2 6
124+
** / \ / \ / \ \
125+
** 1 3 5 7 1 3 7
126126
**
127127
**************************************************************************
128128
*/
@@ -251,18 +251,18 @@ private static void AssertCase_5(AVLTree<int> avlTree)
251251
{
252252
var avlRoot = avlTree.Root;
253253
Assert.True(avlRoot.Height == 2, "Wrong root height!");
254-
Assert.True(avlRoot.Value == 6, "Wrong root.");
254+
Assert.True(avlRoot.Value == 5, "Wrong root.");
255255
Assert.True(avlRoot.LeftChild.Value == 2, "Wrong left child from root.");
256-
Assert.True(avlRoot.RightChild.Value == 7, "Wrong right child from root.");
256+
Assert.True(avlRoot.RightChild.Value == 6, "Wrong right child from root.");
257257
Assert.True(avlRoot.LeftChild.LeftChild.Value == 1, "Wrong value at {root->left->left}.");
258258
Assert.True(avlRoot.LeftChild.RightChild.Value == 3, "Wrong value at {root->left->right}.");
259-
Assert.True(avlRoot.RightChild.LeftChild.Value == 5, "Wrong value at {root->right->left}.");
260-
Assert.True(avlRoot.RightChild.RightChild == null, "Wrong value at {root->right->right}.");
259+
Assert.True(avlRoot.RightChild.LeftChild == null, "Wrong value at {root->right->left}.");
260+
Assert.True(avlRoot.RightChild.RightChild.Value == 7, "Wrong value at {root->right->right}.");
261261

262262
Assert.True(
263263
avlRoot.LeftChild.LeftChild.Height == 0
264264
&& avlRoot.LeftChild.RightChild.Height == 0
265-
&& avlRoot.RightChild.LeftChild.Height == 0
265+
&& avlRoot.RightChild.RightChild.Height == 0
266266
,
267267
"Wrong heights at the leaf nodes!.");
268268

UnitTest/DataStructuresTests/BinarySearchTreeTest.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,13 +126,12 @@ public static void AssertTreeWithUniqueElements()
126126
var inserting_unique_passed = true;
127127
try
128128
{
129-
// Insert values with duplicates
129+
// Insert unique values
130130
binarySearchTree.Insert(values);
131-
inserting_duplicates_passed = true;
132131
}
133132
catch
134133
{
135-
inserting_duplicates_passed = false;
134+
inserting_unique_passed = false;
136135
}
137136

138137
Assert.True(inserting_unique_passed, "Fail! Inserting unique elements should pass!");

UnitTest/DataStructuresTests/HashTableSeparateChainingTest.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,11 @@ public static void DoTest()
101101
Assert.True(studentsMarks.Count == 3);
102102

103103
KeyValuePair<string, int>[] array = new KeyValuePair<string, int>[studentsMarks.Count];
104-
studentsMarks.CopyTo(array, 0);
104+
105+
if (studentsMarks != null)
106+
{
107+
studentsMarks.CopyTo(array, 0);
108+
}
105109

106110
Assert.True(array.Length == studentsMarks.Count);
107111
}

UnitTest/UnitTest.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55

66
<ItemGroup>
77
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />
8-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.8.0" />
9-
<PackageReference Include="xunit" Version="2.4.0" />
10-
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
8+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.0.1" />
9+
<PackageReference Include="xunit" Version="2.4.1" />
10+
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1" />
1111
</ItemGroup>
1212

1313
<ItemGroup>

0 commit comments

Comments
 (0)