Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Valerija hanaeva #52

Open
wants to merge 35 commits into
base: Valerija_Hanaeva
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
e2e2b08
Update README.md
markkket Feb 8, 2022
c7a4c7d
Create CyclicShift
markkket Jun 3, 2022
c2b43d3
Create CircularStr
markkket Jun 3, 2022
0571e8d
Create FindSubstr
markkket Jun 3, 2022
a9936da
Create PeriodStr
markkket Jun 3, 2022
20c4a63
Create MinSeg
markkket Jun 3, 2022
b6907e6
Create NearSmall
markkket Jun 3, 2022
0c7ac59
Create Psp
markkket Jun 3, 2022
4f710fa
Create SORT
markkket Jun 3, 2022
bcf1edd
Create BinarTreeBranch
markkket Jun 3, 2022
bafb9f3
Create IsTreeBalanced
markkket Jun 3, 2022
2c6c697
Create Bubble_Sort
markkket Jun 3, 2022
9c0f661
Create InversionCount
markkket Jun 3, 2022
8e71ea7
Create MergeSort
markkket Jun 3, 2022
c350b7a
Create NumberDif
markkket Jun 3, 2022
e101e13
Create PairSort
markkket Jun 3, 2022
aa9843b
Create RadixSort
markkket Jun 3, 2022
5c8dd2e
Create Warehouse
markkket Jun 3, 2022
e246850
Create AplusB
markkket Jun 3, 2022
1c97d19
Create InversionCountTest
markkket Jun 4, 2022
b5eda64
Create MergeTest
markkket Jun 4, 2022
d95065f
Create NumberDifTest
markkket Jun 4, 2022
ec135c8
Create PairSortTest
markkket Jun 4, 2022
ed6a061
Create RadixSortTest
markkket Jun 4, 2022
cbbef55
Create WarehouseTest
markkket Jun 4, 2022
d8cbabb
Create CircularStrTest
markkket Jun 4, 2022
62d7bc1
Create CyclingShiftTest
markkket Jun 4, 2022
4bc7f7d
Create FindSubstrTest
markkket Jun 4, 2022
6146160
Create PeriodStrTest
markkket Jun 4, 2022
cd1db19
Create MinSegTest
markkket Jun 4, 2022
e46348f
Create NearSmalTest
markkket Jun 4, 2022
a74eb03
Create PspTest
markkket Jun 4, 2022
0c09123
Create SortTest
markkket Jun 4, 2022
e93c9f4
Create BinarTreeBranchTest
markkket Jun 4, 2022
0dafcde
Create IsTreeBalancedTest
markkket Jun 4, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions CourseApp.Tests/Module2/InversionCountTest
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
namespace CourseApp.Tests.Module2
{
using System;
using System.Collections.Generic;
using System.IO;
using CourseApp.Module2;
using Xunit;

[Collection("Sequential")]
public class InversionCountTest : IDisposable
{
private const string Inp1 = @"1
1";

private const string Out1 = @"0";

private const string Inp2 = @"5
5 4 3 2 1";

private const string Out2 = @"10";

public void Dispose()
{
var standardOut = new StreamWriter(Console.OpenStandardOutput());
standardOut.AutoFlush = true;
var standardIn = new StreamReader(Console.OpenStandardInput());
Console.SetOut(standardOut);
Console.SetIn(standardIn);
}

[Theory]
[InlineData(Inp1, Out1)]
[InlineData(Inp2, Out2)]
public void Test1(string input, string expected)
{
var stringWriter = new StringWriter();
Console.SetOut(stringWriter);

var stringReader = new StringReader(input);
Console.SetIn(stringReader);

// act
InversionCount.Start();

// assert
var output = stringWriter.ToString().Split(Environment.NewLine, StringSplitOptions.RemoveEmptyEntries);
var result = string.Join(Environment.NewLine, output);

Assert.Equal($"{expected}", result);
}
}
}
63 changes: 63 additions & 0 deletions CourseApp.Tests/Module2/MergeTest
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
namespace CourseApp.Tests.Module2
{
using System;
using System.Collections.Generic;
using System.IO;
using CourseApp.Module2;
using Xunit;

[Collection("Sequential")]
public class MergeSortTest : IDisposable
{
private const string Inp1 = @"5
5 4 3 2 1";

private const string Out1 = @"1 2 4 5
4 5 1 2
3 5 1 3
1 5 1 5
1 2 3 4 5";

private const string Inp2 = @"1
1";

private const string Out2 = @"1";

private const string Inp3 = @"2
3 1";

private const string Out3 = @"1 2 1 3
1 3";

public void Dispose()
{
var standardOut = new StreamWriter(Console.OpenStandardOutput());
standardOut.AutoFlush = true;
var standardIn = new StreamReader(Console.OpenStandardInput());
Console.SetOut(standardOut);
Console.SetIn(standardIn);
}

[Theory]
[InlineData(Inp1, Out1)]
[InlineData(Inp2, Out2)]
[InlineData(Inp3, Out3)]
public void Test1(string input, string expected)
{
var stringWriter = new StringWriter();
Console.SetOut(stringWriter);

var stringReader = new StringReader(input);
Console.SetIn(stringReader);

// act
MergeSort.MergeSortMethod();

// assert
var output = stringWriter.ToString().Split(Environment.NewLine, StringSplitOptions.RemoveEmptyEntries);
var result = string.Join(Environment.NewLine, output);

Assert.Equal($"{expected}", result);
}
}
}
46 changes: 46 additions & 0 deletions CourseApp.Tests/Module2/NumberDifTest
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
namespace CourseApp.Tests.Module2
{
using System;
using System.Collections.Generic;
using System.IO;
using CourseApp.Module2;
using Xunit;

[Collection("Sequential")]
public class NumberDifTest : IDisposable
{
private const string Inp1 = @"5
1 0 1 2 0";

private const string Out1 = @"3";

public void Dispose()
{
var standardOut = new StreamWriter(Console.OpenStandardOutput());
standardOut.AutoFlush = true;
var standardIn = new StreamReader(Console.OpenStandardInput());
Console.SetOut(standardOut);
Console.SetIn(standardIn);
}

[Theory]
[InlineData(Inp1, Out1)]
public void Test1(string input, string expected)
{
var stringWriter = new StringWriter();
Console.SetOut(stringWriter);

var stringReader = new StringReader(input);
Console.SetIn(stringReader);

// act
NumberDif.Count_Diff_Method();

// assert
var output = stringWriter.ToString().Split(Environment.NewLine, StringSplitOptions.RemoveEmptyEntries);
var result = string.Join(Environment.NewLine, output);

Assert.Equal($"{expected}", result);
}
}
}
60 changes: 60 additions & 0 deletions CourseApp.Tests/Module2/PairSortTest
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
namespace CourseApp.Tests.Module2
{
using System;
using System.Collections.Generic;
using System.IO;
using CourseApp.Module2;
using Xunit;

[Collection("Sequential")]
public class PairSortTest : IDisposable
{
private const string Inp1 = @"3
20 80
30 90
25 90";

private const string Out1 = @"25 90
30 90
20 80";

private const string Inp2 = @"3
101 80
305 90
200 14";

private const string Out2 = @"305 90
101 80
200 14";

public void Dispose()
{
var standardOut = new StreamWriter(Console.OpenStandardOutput());
standardOut.AutoFlush = true;
var standardIn = new StreamReader(Console.OpenStandardInput());
Console.SetOut(standardOut);
Console.SetIn(standardIn);
}

[Theory]
[InlineData(Inp1, Out1)]
[InlineData(Inp2, Out2)]
public void Test1(string input, string expected)
{
var stringWriter = new StringWriter();
Console.SetOut(stringWriter);

var stringReader = new StringReader(input);
Console.SetIn(stringReader);

// act
PairSort.PairSortMethod();

// assert
var output = stringWriter.ToString().Split(Environment.NewLine, StringSplitOptions.RemoveEmptyEntries);
var result = string.Join(Environment.NewLine, output);

Assert.Equal($"{expected}", result);
}
}
}
82 changes: 82 additions & 0 deletions CourseApp.Tests/Module2/RadixSortTest
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
namespace CourseApp.Tests.Module2
{
using System;
using System.Collections.Generic;
using System.IO;
using CourseApp.Module2;
using Xunit;

[Collection("Sequential")]
public class RadixSortTest : IDisposable
{
private const string Inp1 = @"9
12
32
45
67
98
29
61
35
09";

private const string Out1 = @"Initial array:
12, 32, 45, 67, 98, 29, 61, 35, 09
**
Phase 1
Bucket 0: empty
Bucket 1: 61
Bucket 2: 12, 32
Bucket 3: empty
Bucket 4: empty
Bucket 5: 45, 35
Bucket 6: empty
Bucket 7: 67
Bucket 8: 98
Bucket 9: 29, 09
**
Phase 2
Bucket 0: 09
Bucket 1: 12
Bucket 2: 29
Bucket 3: 32, 35
Bucket 4: 45
Bucket 5: empty
Bucket 6: 61, 67
Bucket 7: empty
Bucket 8: empty
Bucket 9: 98
**
Sorted array:
09, 12, 29, 32, 35, 45, 61, 67, 98";

public void Dispose()
{
var standardOut = new StreamWriter(Console.OpenStandardOutput());
standardOut.AutoFlush = true;
var standardIn = new StreamReader(Console.OpenStandardInput());
Console.SetOut(standardOut);
Console.SetIn(standardIn);
}

[Theory]
[InlineData(Inp1, Out1)]
public void Test1(string input, string expected)
{
var stringWriter = new StringWriter();
Console.SetOut(stringWriter);

var stringReader = new StringReader(input);
Console.SetIn(stringReader);

// act
RadixSort.Start();

// assert
var output = stringWriter.ToString().Split(Environment.NewLine, StringSplitOptions.RemoveEmptyEntries);
var result = string.Join(Environment.NewLine, output);

Assert.Equal($"{expected}", result);
}
}
}
52 changes: 52 additions & 0 deletions CourseApp.Tests/Module2/WarehouseTest
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
namespace CourseApp.Tests.Module2
{
using System;
using System.Collections.Generic;
using System.IO;
using CourseApp.Module2;
using Xunit;

[Collection("Sequential")]
public class WarehouseTest : IDisposable
{
private const string Inp1 = @"5
1 50 3 4 3
16
1 2 3 4 5 1 3 3 4 5 5 5 5 5 4 5";

private const string Out1 = @"yes
no
no
no
yes";

public void Dispose()
{
var standardOut = new StreamWriter(Console.OpenStandardOutput());
standardOut.AutoFlush = true;
var standardIn = new StreamReader(Console.OpenStandardInput());
Console.SetOut(standardOut);
Console.SetIn(standardIn);
}

[Theory]
[InlineData(Inp1, Out1)]
public void Test1(string input, string expected)
{
var stringWriter = new StringWriter();
Console.SetOut(stringWriter);

var stringReader = new StringReader(input);
Console.SetIn(stringReader);

// act
Warehouse.Input_Values();

// assert
var output = stringWriter.ToString().Split(Environment.NewLine, StringSplitOptions.RemoveEmptyEntries);
var result = string.Join(Environment.NewLine, output);

Assert.Equal($"{expected}", result);
}
}
}
Loading