add test for sum
This commit is contained in:
parent
ec2bd88342
commit
6303f4c28e
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,71 +1,12 @@
|
||||
{
|
||||
"Version": 1,
|
||||
"WorkspaceRootPath": "C:\\Users\\Hackaton\\source\\repos\\MatrixSolution\\MatrixSol\\",
|
||||
"Documents": [
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{E812BC68-6D94-4469-B05B-ADCA58D74C56}|MatrixProject\\MatrixProject.csproj|c:\\users\\hackaton\\source\\repos\\matrixsolution\\matrixsol\\matrixproject\\matrix.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
||||
"RelativeMoniker": "D:0:0:{E812BC68-6D94-4469-B05B-ADCA58D74C56}|MatrixProject\\MatrixProject.csproj|solutionrelative:matrixproject\\matrix.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
|
||||
},
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{67C8B376-25F3-481A-8684-66E651A0461B}|MatrixProject.Test\\MatrixProject.Test.csproj|c:\\users\\hackaton\\source\\repos\\matrixsolution\\matrixsol\\matrixproject.test\\matrixtest.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
||||
"RelativeMoniker": "D:0:0:{67C8B376-25F3-481A-8684-66E651A0461B}|MatrixProject.Test\\MatrixProject.Test.csproj|solutionrelative:matrixproject.test\\matrixtest.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
|
||||
},
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{67C8B376-25F3-481A-8684-66E651A0461B}|MatrixProject.Test\\MatrixProject.Test.csproj|c:\\users\\hackaton\\source\\repos\\matrixsolution\\matrixsol\\matrixproject.test\\matrixproject.test.csproj||{FA3CD31E-987B-443A-9B81-186104E8DAC1}|",
|
||||
"RelativeMoniker": "D:0:0:{67C8B376-25F3-481A-8684-66E651A0461B}|MatrixProject.Test\\MatrixProject.Test.csproj|solutionrelative:matrixproject.test\\matrixproject.test.csproj||{FA3CD31E-987B-443A-9B81-186104E8DAC1}|"
|
||||
}
|
||||
],
|
||||
"Documents": [],
|
||||
"DocumentGroupContainers": [
|
||||
{
|
||||
"Orientation": 0,
|
||||
"VerticalTabListWidth": 256,
|
||||
"DocumentGroups": [
|
||||
{
|
||||
"DockedWidth": 200,
|
||||
"SelectedChildIndex": 2,
|
||||
"Children": [
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 2,
|
||||
"Title": "MatrixProject.Test.csproj",
|
||||
"DocumentMoniker": "C:\\Users\\Hackaton\\source\\repos\\MatrixSolution\\MatrixSol\\MatrixProject.Test\\MatrixProject.Test.csproj",
|
||||
"RelativeDocumentMoniker": "MatrixProject.Test\\MatrixProject.Test.csproj",
|
||||
"ToolTip": "C:\\Users\\Hackaton\\source\\repos\\MatrixSolution\\MatrixSol\\MatrixProject.Test\\MatrixProject.Test.csproj",
|
||||
"RelativeToolTip": "MatrixProject.Test\\MatrixProject.Test.csproj",
|
||||
"ViewState": "AgIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000758|",
|
||||
"WhenOpened": "2024-10-08T07:03:47.001Z",
|
||||
"EditorCaption": ""
|
||||
},
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 1,
|
||||
"Title": "MatrixTest.cs",
|
||||
"DocumentMoniker": "C:\\Users\\Hackaton\\source\\repos\\MatrixSolution\\MatrixSol\\MatrixProject.Test\\MatrixTest.cs",
|
||||
"RelativeDocumentMoniker": "MatrixProject.Test\\MatrixTest.cs",
|
||||
"ToolTip": "C:\\Users\\Hackaton\\source\\repos\\MatrixSolution\\MatrixSol\\MatrixProject.Test\\MatrixTest.cs",
|
||||
"RelativeToolTip": "MatrixProject.Test\\MatrixTest.cs",
|
||||
"ViewState": "AgIAACEAAAAAAAAAAMBCwC0AAAA1AAAAAAAAAA==",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||
"WhenOpened": "2024-10-08T06:41:24.991Z",
|
||||
"EditorCaption": ""
|
||||
},
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 0,
|
||||
"Title": "Matrix.cs",
|
||||
"DocumentMoniker": "C:\\Users\\Hackaton\\source\\repos\\MatrixSolution\\MatrixSol\\MatrixProject\\Matrix.cs",
|
||||
"RelativeDocumentMoniker": "MatrixProject\\Matrix.cs",
|
||||
"ToolTip": "C:\\Users\\Hackaton\\source\\repos\\MatrixSolution\\MatrixSol\\MatrixProject\\Matrix.cs*",
|
||||
"RelativeToolTip": "MatrixProject\\Matrix.cs*",
|
||||
"ViewState": "AgIAABkAAAAAAAAAAAAAACYAAAAeAAAAAAAAAA==",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||
"WhenOpened": "2024-10-08T06:36:26.85Z",
|
||||
"EditorCaption": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
"DocumentGroups": []
|
||||
}
|
||||
]
|
||||
}
|
@ -1,12 +1,88 @@
|
||||
{
|
||||
"Version": 1,
|
||||
"WorkspaceRootPath": "C:\\Users\\Hackaton\\source\\repos\\MatrixSolution\\MatrixSol\\",
|
||||
"Documents": [],
|
||||
"Documents": [
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{67C8B376-25F3-481A-8684-66E651A0461B}|MatrixProject.Test\\MatrixProject.Test.csproj|c:\\users\\hackaton\\source\\repos\\matrixsolution\\matrixsol\\matrixproject.test\\matrixtest.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
||||
"RelativeMoniker": "D:0:0:{67C8B376-25F3-481A-8684-66E651A0461B}|MatrixProject.Test\\MatrixProject.Test.csproj|solutionrelative:matrixproject.test\\matrixtest.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
|
||||
},
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{E812BC68-6D94-4469-B05B-ADCA58D74C56}|MatrixProject\\MatrixProject.csproj|c:\\users\\hackaton\\source\\repos\\matrixsolution\\matrixsol\\matrixproject\\exceptions\\additionexception.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
||||
"RelativeMoniker": "D:0:0:{E812BC68-6D94-4469-B05B-ADCA58D74C56}|MatrixProject\\MatrixProject.csproj|solutionrelative:matrixproject\\exceptions\\additionexception.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
|
||||
},
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{E812BC68-6D94-4469-B05B-ADCA58D74C56}|MatrixProject\\MatrixProject.csproj|c:\\users\\hackaton\\source\\repos\\matrixsolution\\matrixsol\\matrixproject\\matrix.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
||||
"RelativeMoniker": "D:0:0:{E812BC68-6D94-4469-B05B-ADCA58D74C56}|MatrixProject\\MatrixProject.csproj|solutionrelative:matrixproject\\matrix.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
|
||||
},
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{E812BC68-6D94-4469-B05B-ADCA58D74C56}|MatrixProject\\MatrixProject.csproj|c:\\users\\hackaton\\source\\repos\\matrixsolution\\matrixsol\\matrixproject\\matrixproject.csproj||{FA3CD31E-987B-443A-9B81-186104E8DAC1}|",
|
||||
"RelativeMoniker": "D:0:0:{E812BC68-6D94-4469-B05B-ADCA58D74C56}|MatrixProject\\MatrixProject.csproj|solutionrelative:matrixproject\\matrixproject.csproj||{FA3CD31E-987B-443A-9B81-186104E8DAC1}|"
|
||||
}
|
||||
],
|
||||
"DocumentGroupContainers": [
|
||||
{
|
||||
"Orientation": 0,
|
||||
"VerticalTabListWidth": 256,
|
||||
"DocumentGroups": []
|
||||
"DocumentGroups": [
|
||||
{
|
||||
"DockedWidth": 200,
|
||||
"SelectedChildIndex": 3,
|
||||
"Children": [
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 2,
|
||||
"Title": "Matrix.cs",
|
||||
"DocumentMoniker": "C:\\Users\\Hackaton\\source\\repos\\MatrixSolution\\MatrixSol\\MatrixProject\\Matrix.cs",
|
||||
"RelativeDocumentMoniker": "MatrixProject\\Matrix.cs",
|
||||
"ToolTip": "C:\\Users\\Hackaton\\source\\repos\\MatrixSolution\\MatrixSol\\MatrixProject\\Matrix.cs*",
|
||||
"RelativeToolTip": "MatrixProject\\Matrix.cs*",
|
||||
"ViewState": "AgIAABwAAAAAAAAAAAAAACQAAAAYAAAAAAAAAA==",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||
"WhenOpened": "2024-10-08T12:39:58.627Z",
|
||||
"EditorCaption": ""
|
||||
},
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 1,
|
||||
"Title": "AdditionException.cs",
|
||||
"DocumentMoniker": "C:\\Users\\Hackaton\\source\\repos\\MatrixSolution\\MatrixSol\\MatrixProject\\Exceptions\\AdditionException.cs",
|
||||
"RelativeDocumentMoniker": "MatrixProject\\Exceptions\\AdditionException.cs",
|
||||
"ToolTip": "C:\\Users\\Hackaton\\source\\repos\\MatrixSolution\\MatrixSol\\MatrixProject\\Exceptions\\AdditionException.cs*",
|
||||
"RelativeToolTip": "MatrixProject\\Exceptions\\AdditionException.cs*",
|
||||
"ViewState": "AgIAAAAAAAAAAAAAAAAAAAsAAAABAAAAAAAAAA==",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||
"WhenOpened": "2024-10-08T12:39:12.74Z",
|
||||
"EditorCaption": ""
|
||||
},
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 3,
|
||||
"Title": "MatrixProject",
|
||||
"DocumentMoniker": "C:\\Users\\Hackaton\\source\\repos\\MatrixSolution\\MatrixSol\\MatrixProject\\MatrixProject.csproj",
|
||||
"RelativeDocumentMoniker": "MatrixProject\\MatrixProject.csproj",
|
||||
"ToolTip": "C:\\Users\\Hackaton\\source\\repos\\MatrixSolution\\MatrixSol\\MatrixProject\\MatrixProject.csproj*",
|
||||
"RelativeToolTip": "MatrixProject\\MatrixProject.csproj*",
|
||||
"ViewState": "AgIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000758|",
|
||||
"WhenOpened": "2024-10-08T12:37:06.153Z",
|
||||
"EditorCaption": ""
|
||||
},
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 0,
|
||||
"Title": "MatrixTest.cs",
|
||||
"DocumentMoniker": "C:\\Users\\Hackaton\\source\\repos\\MatrixSolution\\MatrixSol\\MatrixProject.Test\\MatrixTest.cs",
|
||||
"RelativeDocumentMoniker": "MatrixProject.Test\\MatrixTest.cs",
|
||||
"ToolTip": "C:\\Users\\Hackaton\\source\\repos\\MatrixSolution\\MatrixSol\\MatrixProject.Test\\MatrixTest.cs*",
|
||||
"RelativeToolTip": "MatrixProject.Test\\MatrixTest.cs*",
|
||||
"ViewState": "AgIAACsAAAAAAAAAAAAAwDcAAAAAAAAAAAAAAA==",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||
"WhenOpened": "2024-10-08T12:27:34.933Z",
|
||||
"EditorCaption": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
Binary file not shown.
@ -1,3 +1,4 @@
|
||||
using MatrixProject.Exceptions;
|
||||
using System.Numerics;
|
||||
using System.Reflection;
|
||||
|
||||
@ -23,24 +24,24 @@ public class MatrixTest
|
||||
public void CheckColumnsBeforeInitMatrix()
|
||||
{
|
||||
Matrix matrix = new Matrix();
|
||||
|
||||
|
||||
Assert.Equal(5, matrix.Columns);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[MemberData(nameof(testTwoDimArray))]
|
||||
public void CheckFillMatrixInDefaultConstructor(int row, int column, int fillNumber, double[,] testArray) {
|
||||
|
||||
|
||||
Matrix matrix = new Matrix(row, column, fillNumber);
|
||||
|
||||
|
||||
Assert.True(EqualsTwoDimArray(testArray, matrix));
|
||||
}
|
||||
[Theory]
|
||||
[MemberData(nameof(testMult))]
|
||||
public void CheckMultOnScalar(int row,
|
||||
int column,
|
||||
int fillNumber,
|
||||
int scalar,
|
||||
public void CheckMultOnScalar(int row,
|
||||
int column,
|
||||
int fillNumber,
|
||||
int scalar,
|
||||
double[,] testArray)
|
||||
{
|
||||
|
||||
@ -49,6 +50,12 @@ public class MatrixTest
|
||||
Assert.True(EqualsTwoDimArray(testArray, matrix));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[MemberData(nameof(testSum))]
|
||||
public void CheckSum(Matrix matrix, Matrix matrixTwo) {
|
||||
|
||||
Assert.Throws<AdditionException>(() => matrix += matrixTwo);
|
||||
}
|
||||
|
||||
public static TheoryData<int, int,int, double[,]> testTwoDimArray => new () {
|
||||
|
||||
@ -62,6 +69,10 @@ public class MatrixTest
|
||||
|
||||
{2, 2, 1, 4, new double[2,2]{ {4,4 }, {4,4} }}
|
||||
};
|
||||
public static TheoryData<Matrix, Matrix> testSum => new() {
|
||||
|
||||
{new Matrix(4, 3), new Matrix(3, 4) }
|
||||
};
|
||||
private bool EqualsTwoDimArray(double[,] testMatrix, Matrix matrix) {
|
||||
if(testMatrix.GetLength(0) != matrix.Rows ||
|
||||
testMatrix.GetLength(1) != matrix.Columns) return false;
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -14,7 +14,7 @@ using System.Reflection;
|
||||
[assembly: System.Reflection.AssemblyCompanyAttribute("MatrixProject.Test")]
|
||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+1bd4c3038a77608789d2670603fc673e2fb44392")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+ec2bd8834293e76d62c5b39565b98a44ee2c10be")]
|
||||
[assembly: System.Reflection.AssemblyProductAttribute("MatrixProject.Test")]
|
||||
[assembly: System.Reflection.AssemblyTitleAttribute("MatrixProject.Test")]
|
||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||
|
@ -1 +1 @@
|
||||
febd42cc5d6a1f221977452793563afdd2aaf235cb88f9a3831c0cb0aa26a19d
|
||||
c65c026971ce8e5a2e46719aff82c708f04ff2b67889f2536c4a17561f024d88
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,4 +1,6 @@
|
||||
namespace MatrixProject;
|
||||
using MatrixProject.Exceptions;
|
||||
|
||||
namespace MatrixProject;
|
||||
|
||||
public struct Matrix
|
||||
{
|
||||
@ -30,7 +32,16 @@ public struct Matrix
|
||||
}
|
||||
|
||||
public static Matrix operator +(Matrix matrix, Matrix matrixTwo) {
|
||||
|
||||
if (matrix.Rows != matrixTwo.Rows ||
|
||||
matrix.Columns != matrixTwo.Columns)
|
||||
throw new AdditionException("Строки и столбцы не совпадают");
|
||||
|
||||
for (int i = 0; i < matrix.Rows; i++) {
|
||||
for (int j = 0; j < matrix.Columns; j++){
|
||||
matrix[i, j] += matrixTwo[i, j];
|
||||
}
|
||||
}
|
||||
return matrix;
|
||||
}
|
||||
|
||||
public static Matrix operator *(Matrix matrix, int scalar)
|
||||
|
Binary file not shown.
Binary file not shown.
@ -14,7 +14,7 @@ using System.Reflection;
|
||||
[assembly: System.Reflection.AssemblyCompanyAttribute("MatrixProject")]
|
||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+f83c350fcf6198bb695faa6e42221add9cfeeb3b")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+ec2bd8834293e76d62c5b39565b98a44ee2c10be")]
|
||||
[assembly: System.Reflection.AssemblyProductAttribute("MatrixProject")]
|
||||
[assembly: System.Reflection.AssemblyTitleAttribute("MatrixProject")]
|
||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||
|
@ -1 +1 @@
|
||||
29f12b7459d25fbd0a22e224e4090a32c5918a830b804c4b130ff5ec95cef3ea
|
||||
bda4d90d4bc0f44b22825c6838639d79528858bdd371e36905c9f1edae409df6
|
||||
|
@ -1 +1 @@
|
||||
aba87257896a54787ca9eba077b30914847e929ea645c7f180e4b5dc20668307
|
||||
c7a77033cf4dd5e43ce85f946c107c9b60bcddf90da0f08959950d280bf7c4b9
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user