-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue #321 Write two tests for matrix concatenation
- Loading branch information
Showing
2 changed files
with
119 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// <copyright file="MatrixToolsTests.cs" company="QutEcoacoustics"> | ||
// All code in this file and all associated files are the copyright and property of the QUT Ecoacoustics Research Group (formerly MQUTeR, and formerly QUT Bioacoustics Research Group). | ||
// </copyright> | ||
|
||
namespace Acoustics.Test.TowseyLibrary | ||
{ | ||
using System.Collections.Generic; | ||
using global::TowseyLibrary; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
[TestClass] | ||
public class MatrixToolsTests | ||
{ | ||
[TestMethod] | ||
public void ConcatenateMatrixRows() | ||
{ | ||
double[,] matrix1 = | ||
{ | ||
{ 1.0, 4.0 }, | ||
{ 2.0, 5.0 }, | ||
{ 3.0, 6.0 }, | ||
}; | ||
|
||
double[,] matrix2 = | ||
{ | ||
{ 7.0, 10.0 }, | ||
{ 8.0, 11.0 }, | ||
{ 9.0, 12.0 }, | ||
}; | ||
|
||
double[,] expected = | ||
{ | ||
{ 1.0, 4.0 }, | ||
{ 2.0, 5.0 }, | ||
{ 3.0, 6.0 }, | ||
{ 7.0, 10.0 }, | ||
{ 8.0, 11.0 }, | ||
{ 9.0, 12.0 }, | ||
}; | ||
|
||
var actual = MatrixTools.ConcatenateMatrixRows(matrix1, matrix2); | ||
|
||
CollectionAssert.AreEqual(expected, actual); | ||
} | ||
|
||
[TestMethod] | ||
public void ConcatenateTwoMatrices() | ||
{ | ||
double[,] matrix1 = | ||
{ | ||
{ 1.0, 3.0, 5.0 }, | ||
{ 2.0, 4.0, 6.0 }, | ||
}; | ||
|
||
double[,] matrix2 = | ||
{ | ||
{ 7.0, 9.0 }, | ||
{ 8.0, 10.0 }, | ||
}; | ||
|
||
double[,] expected = | ||
{ | ||
{ 1.0, 3.0, 5.0, 7.0, 9.0 }, | ||
{ 2.0, 4.0, 6.0, 8.0, 10.0 }, | ||
}; | ||
|
||
var actual = MatrixTools.ConcatenateTwoMatrices(matrix1, matrix2); | ||
|
||
CollectionAssert.AreEqual(expected, actual); | ||
} | ||
} | ||
} |