repo_name
stringlengths
1
52
repo_creator
stringclasses
6 values
programming_language
stringclasses
4 values
code
stringlengths
0
9.68M
num_lines
int64
1
234k
C-Sharp
TheAlgorithms
C#
namespace Algorithms.Sorters.String { /// <summary> /// Radix sort is a non-comparative sorting algorithm. It avoids comparison by creating /// and distributing elements into buckets according to their radix. /// Radix sorts can be implemented to start at either the most significant digit (M...
60
C-Sharp
TheAlgorithms
C#
using System; namespace Algorithms.Strings { /// <summary> /// The idea: You compare the pattern with the text from right to left. /// If the text symbol that is compared with the rightmost pattern symbol /// does not occur in the pattern at all, then the pattern can be shifted /// ...
168
C-Sharp
TheAlgorithms
C#
using System; namespace Algorithms.Strings { /// <summary> /// Implements simple algorithms on strings. /// </summary> public static class GeneralStringAlgorithms { /// <summary> /// Finds character that creates longest consecutive substring with single character. //...
43
C-Sharp
TheAlgorithms
C#
using System; namespace Algorithms.Strings { /// <summary> /// <para> /// Hamming distance between two strings of equal length is the number of positions at which the corresponding symbols are different. /// Time complexity is O(n) where n is the length of the string. /// </...
39
C-Sharp
TheAlgorithms
C#
using System; namespace Algorithms.Strings { /// <summary> /// <para> /// Jaro Similarity measures how similar two strings are. /// Result is between 0 and 1 where 0 represnts that there is no similarity between strings and 1 represents equal strings. /// Time complexity...
98
C-Sharp
TheAlgorithms
C#
using System; using System.Linq; namespace Algorithms.Strings { /// <summary> /// <para> /// Jaro–Winkler distance is a string metric measuring an edit distance between two sequences. /// The score is normalized such that 1 means an exact match and 0 means there is no similarity. ...
35
C-Sharp
TheAlgorithms
C#
using System.Collections.Generic; namespace Algorithms.Strings { public class KnuthMorrisPrattSearcher { /// <summary> /// An implementation of Knuth–Morris–Pratt Algorithm. /// Worst case time complexity: O(n + k) /// where n - text length, k - pattern length...
83
C-Sharp
TheAlgorithms
C#
using System; namespace Algorithms.Strings { /// <summary> /// <para> /// Levenshtein distance between two words is the minimum number of single-character edits (insertions, deletions or substitutions) required to change one word into the other. /// </para> /// <para> /// ...
49
C-Sharp
TheAlgorithms
C#
using System.Collections.Generic; // Implements the traditional naive string matching algorithm in C# for TheAlgorithms/C-Sharp. namespace Algorithms.Strings { /// <summary> /// Implements the traditional naive string matching algorithm in C#. /// </summary> public static class NaiveStringSearch ...
44
C-Sharp
TheAlgorithms
C#
using System; using System.Text.RegularExpressions; namespace Algorithms.Strings { /// <summary> /// Palindrome a series of characters or a string that when reversed, /// equals the original string. /// </summary> public static class Palindrome { /// <summary> /// Fu...
40
C-Sharp
TheAlgorithms
C#
using System.Collections.Generic; using System.Linq; namespace Algorithms.Strings { public static class Permutation { /// <summary> /// Returns every anagram of a given word. /// </summary> /// <returns>List of anagrams.</returns> public static List<string> GetEveryUn...
35
C-Sharp
TheAlgorithms
C#
using System; using System.Collections.Generic; namespace Algorithms.Strings { /// <summary> /// The idea: You calculate the hash for the pattern <c>p</c> and the hash values for all the prefixes of the text /// <c>t</c>. /// Now, you can compare a substring in constant time using the calcu...
83
C-Sharp
TheAlgorithms
C#
namespace Algorithms.Strings { /// <summary>Implementation Z-block substring search. /// </summary> public static class ZblockSubstringSearch { /// <summary> /// This algorithm finds all occurrences of a pattern in a text in linear time - O(m+n). /// </summary> public...
70
C-Sharp
TheAlgorithms
C#
using NUnit.Framework; [assembly: Parallelizable(ParallelScope.Children)]
4
C-Sharp
TheAlgorithms
C#
using Algorithms.DataCompression; using NUnit.Framework; using NUnit.Framework.Internal; namespace Algorithms.Tests.Compressors { public class BurrowsWheelerTransformTests { [Test] [TestCase("banana", "nnbaaa", 3)] [TestCase("SIX.MIXED.PIXIES.SIFT.SIXTY.PIXIE.DUST.BOXES", "TEXYDST.E....
51
C-Sharp
TheAlgorithms
C#
using Algorithms.DataCompression; using Algorithms.Sorters.Comparison; using FluentAssertions; using NUnit.Framework; using NUnit.Framework.Internal; namespace Algorithms.Tests.Compressors { public static class HuffmanCompressorTests { [Test] [TestCase("This is a string", "101010110111011101...
64
C-Sharp
TheAlgorithms
C#
using Algorithms.DataCompression; using Algorithms.Knapsack; using NUnit.Framework; using NUnit.Framework.Internal; namespace Algorithms.Tests.Compressors { public static class ShannonFanoCompressorTests { [Test] [TestCase("dddddddddd", "1111111111")] [TestCase("a", "1")] [Te...
48
C-Sharp
TheAlgorithms
C#
using System.Collections.Generic; using Algorithms.DataCompression; using NUnit.Framework; namespace Algorithms.Tests.Compressors { public static class TranslatorTests { [Test] public static void TranslateCorrectly() { // Arrange var translator = new Translato...
30
C-Sharp
TheAlgorithms
C#
using Algorithms.Encoders; using NUnit.Framework; using NUnit.Framework.Internal; namespace Algorithms.Tests.Encoders { public static class CaesarEncoderTests { [Test] public static void DecodedStringIsTheSame([Random(100)] int key) { // Arrange var encoder = ...
26
C-Sharp
TheAlgorithms
C#
using Algorithms.Encoders; using NUnit.Framework; using NUnit.Framework.Internal; using System; namespace Algorithms.Tests.Encoders { public static class FeistelCipherTests { [Test] public static void DecodedStringIsTheSame([Random(100)] uint key) { // Arrange va...
46
C-Sharp
TheAlgorithms
C#
using Algorithms.Encoders; using NUnit.Framework; using NUnit.Framework.Internal; namespace Algorithms.Tests.Encoders { public static class HillEnconderTests { [Test] [Repeat(100)] public static void DecodedStringIsTheSame() { // Arrange var encoder = ...
29
C-Sharp
TheAlgorithms
C#
using System.Collections.Generic; using System.Linq; using Algorithms.Encoders; using NUnit.Framework; namespace Algorithms.Tests.Encoders { public class NysiisEncoderTests { private static readonly string[] Names = { "Jay", "John", "Jane", "Zayne", "Guerra", "Iga", "Cowan", "Louisa...
33
C-Sharp
TheAlgorithms
C#
using System.Collections.Generic; using System.Linq; using Algorithms.Encoders; using NUnit.Framework; namespace Algorithms.Tests.Encoders { public static class SoundexEncoderTest { private static readonly string[] Names = { "Robert", "Rupert", "Rubin", "Ashcraft", "Ashcroft", "Tymc...
28
C-Sharp
TheAlgorithms
C#
using System; using Algorithms.Encoders; using NUnit.Framework; using NUnit.Framework.Internal; namespace Algorithms.Tests.Encoders { public static class VigenereEncoderTests { [Test] [Repeat(100)] public static void DecodedStringIsTheSame() { // Arrange ...
57
C-Sharp
TheAlgorithms
C#
using Algorithms.Graph; using DataStructures.Graph; using NUnit.Framework; using System.Collections.Generic; namespace Algorithms.Tests.Graph { public class BreadthFirstSearchTests { [Test] public void VisitAll_ShouldCountNumberOfVisitedVertix_ResultShouldBeTheSameAsNumberOfVerticesInGraph() ...
133
C-Sharp
TheAlgorithms
C#
using Algorithms.Graph; using NUnit.Framework; using DataStructures.BinarySearchTree; using System; namespace Algorithms.Tests.Graph { public static class BreadthFirstTreeTraversalTests { [Test] public static void CorrectLevelOrderTraversal() { // Arrange int[] c...
94
C-Sharp
TheAlgorithms
C#
using Algorithms.Graph; using DataStructures.Graph; using NUnit.Framework; using System.Collections.Generic; namespace Algorithms.Tests.Graph { public class DepthFirstSearchTests { [Test] public void VisitAll_ShouldCountNumberOfVisitedVertix_ResultShouldBeTheSameAsNumberOfVerticesInGraph() ...
131
C-Sharp
TheAlgorithms
C#
using Algorithms.Graph; using DataStructures.Graph; using NUnit.Framework; using FluentAssertions; namespace Algorithms.Tests.Graph { public class FloydWarshallTests { [Test] public void CorrectMatrixTest() { var graph = new DirectedWeightedGraph<int>(10); var v...
58
C-Sharp
TheAlgorithms
C#
using Algorithms.Graph; using DataStructures.Graph; using NUnit.Framework; using FluentAssertions; using System.Collections.Generic; using System.Linq; namespace Algorithms.Tests.Graph { public class KosarajuTests { [Test] public void GetRepresentativesTest() { // Create a ...
104
C-Sharp
TheAlgorithms
C#
using System; using Algorithms.Graph.Dijkstra; using DataStructures.Graph; using FluentAssertions; using NUnit.Framework; namespace Algorithms.Tests.Graph.Dijkstra { [TestFixture] public class DijkstraTests { [Test] public void DijkstraTest1_Success() { // here test c...
230
C-Sharp
TheAlgorithms
C#
using Algorithms.Graph.MinimumSpanningTree; using FluentAssertions; using NUnit.Framework; using System; using System.Collections.Generic; using System.Linq; namespace Algorithms.Tests.Graph.MinimumSpanningTree { internal class KruskalTests { [Test] public void ValidateGraph_adjWrongSize_Throws...
729
C-Sharp
TheAlgorithms
C#
using Algorithms.Graph.MinimumSpanningTree; using FluentAssertions; using NUnit.Framework; using System; using System.Linq; namespace Algorithms.Tests.Graph.MinimumSpanningTree { internal class PrimTests { [Test] public void ValidateMatrix_WrongSize_ThrowsException() { // Wr...
396
C-Sharp
TheAlgorithms
C#
using System.Collections.Generic; namespace Algorithms.Tests.Helpers { internal class IntComparer : IComparer<int> { public int Compare(int x, int y) => x.CompareTo(y); } }
10
C-Sharp
TheAlgorithms
C#
using NUnit.Framework; namespace Algorithms.Tests.Helpers { internal static class RandomHelper { public static (int[] correctArray, int[] testArray) GetArrays(int n) { var testArr = new int[n]; var correctArray = new int[n]; for (var i = 0; i < n; i++) ...
53
C-Sharp
TheAlgorithms
C#
using System; using Algorithms.Knapsack; using NUnit.Framework; using FluentAssertions; namespace Algorithms.Tests.Knapsack { public static class BranchAndBoundKnapsackSolverTests { [Test] public static void BranchAndBoundTest_Example1_Success() { // Arrange var ...
116
C-Sharp
TheAlgorithms
C#
using System; using System.Linq; using Algorithms.Knapsack; using NUnit.Framework; namespace Algorithms.Tests.Knapsack { public static class DynamicProgrammingKnapsackSolverTests { [Test] public static void SmallSampleOfChar() { //Arrange var items = new[] { '...
105
C-Sharp
TheAlgorithms
C#
using System.Linq; using Algorithms.Knapsack; using NUnit.Framework; namespace Algorithms.Tests.Knapsack { public static class NaiveKnapsackSolverTests { [Test] public static void TakesHalf( [Random(0, 1000, 100, Distinct = true)] int length) { //A...
27
C-Sharp
TheAlgorithms
C#
using NUnit.Framework; using Algorithms.LinearAlgebra.Distances; using FluentAssertions; using System; namespace Algorithms.Tests.LinearAlgebra.Distances { public static class EuclideanTests { /// <summary> /// Test the result given by Euclidean distance function. /// </summary> ...
39
C-Sharp
TheAlgorithms
C#
using NUnit.Framework; using Algorithms.LinearAlgebra.Distances; using FluentAssertions; using System; namespace Algorithms.Tests.LinearAlgebra.Distances { public class ManhattanTests { /// <summary> /// Test the result given by Manhattan distance function. /// </summary> /// <...
41
C-Sharp
TheAlgorithms
C#
using System; using Algorithms.LinearAlgebra.Eigenvalue; using FluentAssertions; using NUnit.Framework; using Utilities.Extensions; namespace Algorithms.Tests.LinearAlgebra.Eigenvalue { public class PowerIterationTests { private static readonly object[] DominantVectorTestCases = { n...
75
C-Sharp
TheAlgorithms
C#
using Algorithms.ModularArithmetic; using NUnit.Framework; using System; using System.Collections.Generic; using System.Numerics; namespace Algorithms.Tests.ModularArithmetic { public static class ChineseRemainderTheoremTest { [Test] public static void TestCompute1() { var e...
194
C-Sharp
TheAlgorithms
C#
using Algorithms.ModularArithmetic; using NUnit.Framework; using System.Numerics; namespace Algorithms.Tests.ModularArithmetic { public static class ExtendedEuclideanAlgorithmTest { [Test] [TestCase(240, 46, 2, -9, 47)] [TestCase(46, 240, 2, 47, -9)] [TestCase(2, 3, 1, -1, 1)] ...
56
C-Sharp
TheAlgorithms
C#
using Algorithms.ModularArithmetic; using NUnit.Framework; using System; using System.Numerics; namespace Algorithms.Tests.ModularArithmetic { public static class ModularMultiplicativeInverseTest { [Test] [TestCase(2, 3, 2)] [TestCase(1, 1, 0)] [TestCase(13, 17, 4)] publ...
69
C-Sharp
TheAlgorithms
C#
using System; using Algorithms.Numeric; using FluentAssertions; using NUnit.Framework; namespace Algorithms.Tests.Numeric { public static class AliquotSumCalculatorTests { [Test] [TestCase(1, 0)] [TestCase(3, 1)] [TestCase(25, 6)] [TestCase(99, 57)] public sta...
38
C-Sharp
TheAlgorithms
C#
using Algorithms.Numeric; using NUnit.Framework; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Algorithms.Tests.Numeric { public static class AmicableNumbersTest { [Test] [TestCase(220, 284)] [TestCase(1184,...
30
C-Sharp
TheAlgorithms
C#
using Algorithms.Numeric; using NUnit.Framework; using System; using System.Collections.Generic; namespace Algorithms.Tests.Numeric { public class AutomorphicNumberTests { [TestCase(1)] [TestCase(5)] [TestCase(6)] [TestCase(25)] [TestCase(76)] [TestCase(376)] ...
115
C-Sharp
TheAlgorithms
C#
using System; using System.Numerics; using Algorithms.Numeric; using NUnit.Framework; namespace Algorithms.Tests.Numeric { public static class BinomialCoefficientTests { [TestCase(4, 2, 6)] [TestCase(7, 3, 35)] public static void CalculateFromPairs(int n, int k, int expected) { ...
36
C-Sharp
TheAlgorithms
C#
using System; using System.Collections.Generic; using Algorithms.Numeric; using FluentAssertions; using NUnit.Framework; namespace Algorithms.Tests.Numeric { public static class EulerMethodTest { [Test] public static void TestLinearEquation() { Func<double, double, double> e...
63
C-Sharp
TheAlgorithms
C#
using System; using System.Numerics; using Algorithms.Numeric; using NUnit.Framework; namespace Algorithms.Tests.Numeric { public static class FactorialTests { [TestCase(0, "1")] [TestCase(1, "1")] [TestCase(4, "24")] [TestCase(10, "3628800")] [TestCase(18, "640237370...
41
C-Sharp
TheAlgorithms
C#
using System; using Algorithms.Numeric; using NUnit.Framework; namespace Algorithms.Tests.Numeric { /// <summary> /// Class for testing Gauss-Jordan Elimination Algorithm. /// </summary> public static class GaussJordanEliminationTests { [Test] public static void NonSquaredMat...
41
C-Sharp
TheAlgorithms
C#
using System; using Algorithms.Numeric; using NUnit.Framework; namespace Algorithms.Tests.Numeric; public class JosephusProblemTest { [TestCase(10, 0)] [TestCase(10, -1)] public void JosephusProblemInvalidStepSize(long groupSize, long step) { Assert.Throws(Is.TypeOf<ArgumentException>() ...
38
C-Sharp
TheAlgorithms
C#
using Algorithms.Numeric; using NUnit.Framework; using System; namespace Algorithms.Tests.Numeric { public static class KeithNumberTest { [Test] [TestCase(14)] [TestCase(47)] [TestCase(197)] [TestCase(7909)] public static void KeithNumberWork(int number) ...
34
C-Sharp
TheAlgorithms
C#
using Algorithms.Numeric; using NUnit.Framework; namespace Algorithms.Tests.Numeric { public class KrishnamurthyNumberCheckerTests { [TestCase(1)] [TestCase(2)] [TestCase(145)] [TestCase(40585)] public void KrishnamurthyNumberCheckerKnownNumbers(int number) { ...
37
C-Sharp
TheAlgorithms
C#
using System; using System.Numerics; using Algorithms.Numeric; using NUnit.Framework; namespace Algorithms.Tests.Numeric { public static class MillerRabinPrimalityTest { [TestCase("7", ExpectedResult = true)] // true [TestCase("47", ExpectedResult = true)] // true [TestCase("2478941090...
48
C-Sharp
TheAlgorithms
C#
using Algorithms.Numeric; using System; using NUnit.Framework; using FluentAssertions; namespace Algorithms.Tests.Numeric { public class ModularExponentiationTest { [Test] [TestCase(3, 6, 11, 3)] [TestCase(5, 3, 13, 8)] [TestCase(2, 7, 17, 9)] [TestCase(7, 4, 16, 1)] ...
37
C-Sharp
TheAlgorithms
C#
using Algorithms.Numeric; using NUnit.Framework; namespace Algorithms.Tests.Numeric { public static class NarcissisticNumberTest { [Test] [TestCase(2, ExpectedResult = true)] [TestCase(3, ExpectedResult = true)] [TestCase(28, ExpectedResult = false)] [TestCase(153, Ex...
27
C-Sharp
TheAlgorithms
C#
using System; using System.Numerics; using NUnit.Framework; namespace Algorithms.Tests.Numeric; public class NewtonSquareRootTests { private static readonly object[] CalculateSquareRootInput = { new object[] {BigInteger.One, BigInteger.One}, new object[] {new BigInteger(221295376), new BigI...
45
C-Sharp
TheAlgorithms
C#
using System; using Algorithms.Numeric; using NUnit.Framework; namespace Algorithms.Tests.Numeric { public static class PerfectNumberTests { [Test] [TestCase(6)] [TestCase(28)] [TestCase(496)] [TestCase(8128)] public static void PerfectNumberWork(int number) ...
36
C-Sharp
TheAlgorithms
C#
using Algorithms.Numeric; using NUnit.Framework; namespace Algorithms.Tests.Numeric { public static class PerfectSquareTests { [Test] [TestCase(-4, ExpectedResult = false)] [TestCase(4, ExpectedResult = true)] [TestCase(9, ExpectedResult = true)] [TestCase(10, Expecte...
28
C-Sharp
TheAlgorithms
C#
using Algorithms.Numeric; using FluentAssertions; using NUnit.Framework; using System; using System.Collections.Generic; namespace Algorithms.Tests.Numeric { public static class RungeKuttaTest { [Test] public static void TestLinearEquation() { Func<double, double, double> ex...
44
C-Sharp
TheAlgorithms
C#
using System; using System.Linq; using Algorithms.Numeric.Decomposition; using NUnit.Framework; using Utilities.Extensions; namespace Algorithms.Tests.Numeric.Decomposition { public class LuTests { private readonly double epsilon = Math.Pow(10, -6); [Test] public void DecomposeIdentity...
147
C-Sharp
TheAlgorithms
C#
using System; using Algorithms.Numeric.Series; using NUnit.Framework; namespace Algorithms.Tests.Numeric.Decomposition { public class MaclaurinTests { [TestCase(0.01, 3, 0.01)] [TestCase(1, 7, 0.001)] [TestCase(-1.2, 7, 0.001)] public void Exp_TermsForm_ValidCases(double point, ...
132
C-Sharp
TheAlgorithms
C#
using System; using Algorithms.Numeric.Decomposition; using FluentAssertions; using NUnit.Framework; using Utilities.Extensions; using M = Utilities.Extensions.MatrixExtensions; using V = Utilities.Extensions.VectorExtensions; namespace Algorithms.Tests.Numeric.Decomposition { public class SvdTests { [...
139
C-Sharp
TheAlgorithms
C#
using Algorithms.Numeric.Factorization; using NUnit.Framework; namespace Algorithms.Tests.Numeric.Factorization { public static class TrialDivisionFactorizerTests { [Test] [TestCase(2)] [TestCase(3)] [TestCase(29)] [TestCase(31)] public static void PrimeNumberFac...
48
C-Sharp
TheAlgorithms
C#
using Algorithms.Numeric.GreatestCommonDivisor; using NUnit.Framework; namespace Algorithms.Tests.Numeric.GreatestCommonDivisor { public static class BinaryGreatestCommonDivisorFinderTests { [Test] [TestCase(2, 3, 1)] [TestCase(1, 1, 1)] [TestCase(13, 17, 1)] [TestCas...
31
C-Sharp
TheAlgorithms
C#
using Algorithms.Numeric.GreatestCommonDivisor; using NUnit.Framework; namespace Algorithms.Tests.Numeric.GreatestCommonDivisor { public static class EuclideanGreatestCommonDivisorFinderTests { [Test] [TestCase(2, 3, 1)] [TestCase(1, 1, 1)] [TestCase(13, 17, 1)] [Test...
31
C-Sharp
TheAlgorithms
C#
using NUnit.Framework; using Utilities.Extensions; namespace Algorithms.Tests.Numeric.PseudoInverse { public static class PseudoInverseTests { [Test] public static void SquaredMatrixInverseWorks() { // Arrange var inMat = new double[,] { { 2, 4, 6 }, { 2, 0, 2...
46
C-Sharp
TheAlgorithms
C#
using Algorithms.Other; using NUnit.Framework; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Algorithms.Tests.Other { public static class DecisionsConvolutionsTest { [Test] public static void Verify_Linear_Convoluti...
66
C-Sharp
TheAlgorithms
C#
using Algorithms.Other; using NUnit.Framework; using NUnit.Framework.Internal; namespace Algorithms.Tests.Other { public static class FermatPrimeCheckerTests { [Test] [TestCase(5, true)] [TestCase(2633, true)] [TestCase(9439, true)] [TestCase(1, false)] [TestC...
29
C-Sharp
TheAlgorithms
C#
using System; using System.Drawing; using FluentAssertions; using NUnit.Framework; namespace Algorithms.Tests.Other { public static class Tests { private static readonly Color Black = Color.FromArgb(255, 0, 0, 0); private static readonly Color Green = Color.FromArgb(255, 0, 255, 0); pri...
106
C-Sharp
TheAlgorithms
C#
using Algorithms.Other; using NUnit.Framework; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Algorithms.Tests.Other { public static class GaussOptimizationTest { [Test] public static void Verify_Gauss_Optimization_P...
102
C-Sharp
TheAlgorithms
C#
using System; using Algorithms.Other; using NUnit.Framework; namespace Algorithms.Tests.Other { public static class GeoLocationTests { [Test] [TestCase(53.430488d, -2.96129d, 53.430488d, -2.96129d, 0d)] [TestCase(53.430971d, -2.959806d, 53.430242d, -2.960830d, 105d)] public s...
27
C-Sharp
TheAlgorithms
C#
using Algorithms.Other; using NUnit.Framework; namespace Algorithms.Tests.Other { public static class Int2BinaryTests { [Test] [TestCase((ushort)0, "0000000000000000")] [TestCase((ushort)0b1, "0000000000000001")] [TestCase((ushort)0b0001010100111000, "0001010100111000")] ...
69
C-Sharp
TheAlgorithms
C#
using System; using System.Globalization; using Algorithms.Other; using NUnit.Framework; namespace Algorithms.Tests.Other { /// <summary> /// A class for testing the Meeus's Julian Easter algorithm. /// </summary> public static class JulianEasterTest { private static readonly JulianCale...
33
C-Sharp
TheAlgorithms
C#
using System; using System.Collections.Generic; using System.Drawing; using System.Numerics; using Algorithms.Other; using FluentAssertions; using NUnit.Framework; namespace Algorithms.Tests.Other { public static class KochSnowflakeTest { [Test] public static void TestIterateMethod() { ...
53
C-Sharp
TheAlgorithms
C#
using Algorithms.Other; using NUnit.Framework; namespace Algorithms.Tests.Other { /// <summary> /// A class for testing the Luhn algorithm. /// </summary> public class LuhnTests { [Test] [TestCase("89014103211118510720")] // ICCID [TestCase("071052120")] // Social Sec...
65
C-Sharp
TheAlgorithms
C#
using System; using System.Drawing; using Algorithms.Other; using NUnit.Framework; namespace Algorithms.Tests.Other { public static class MandelbrotTest { [Test] public static void BitmapWidthIsZeroOrNegative_ThrowsArgumentOutOfRangeException() { Assert.Throws<ArgumentOutOfR...
51
C-Sharp
TheAlgorithms
C#
using Algorithms.Other; using NUnit.Framework; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Algorithms.Tests.Other { public static class ParetoOptimizationTests { [Test] public static void Verify_Pareto_Optimizatio...
47
C-Sharp
TheAlgorithms
C#
using Algorithms.Other; using NUnit.Framework; namespace Algorithms.Tests.Other { public class PollardsRhoFactorizingTests { [TestCase(8051, 97)] [TestCase(105, 21)] [TestCase(253, 11)] [TestCase(10403, 101)] [TestCase(187, 11)] public void SimpleTest(int number,...
20
C-Sharp
TheAlgorithms
C#
using System; using Algorithms.Other; using FluentAssertions; using NUnit.Framework; namespace Algorithms.Tests.Other { public static class RgbHsvConversionTest { [Test] public static void HueOutOfRange_ThrowsArgumentOutOfRangeException() { Action act = () => RgbHsvConversio...
86
C-Sharp
TheAlgorithms
C#
using System.Numerics; using Algorithms.Other; using FluentAssertions; using NUnit.Framework; namespace Algorithms.Tests.Other { public static class SieveOfEratosthenesTests { private static readonly long[] First10000PrimeNumbers = { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 4...
685
C-Sharp
TheAlgorithms
C#
using Algorithms.Other; using NUnit.Framework; namespace Algorithms.Tests.Other { public class WelfordsVarianceTest { [Test] public void WelfordVariance_Example1() { var welfordsVariance = new WelfordsVariance(); welfordsVariance.AddValue(4); welfords...
164
C-Sharp
TheAlgorithms
C#
using System.Linq; using Algorithms.Problems.CoinChange; using FluentAssertions; using NUnit.Framework; namespace Algorithms.Tests.Problems.CoinChange.Dynamic { [TestFixture] public class GenerateChangesDictionaryTests { [Test] public void GenerateChangesDictionaryTest_Success() ...
27
C-Sharp
TheAlgorithms
C#
using System; using System.Linq; using Algorithms.Problems.CoinChange; using FluentAssertions; using NUnit.Framework; namespace Algorithms.Tests.Problems.CoinChange.Dynamic { [TestFixture] public class GenerateSingleCoinChangesTests { [Test] public void GenerateSingleCoinChangesTests_Suc...
97
C-Sharp
TheAlgorithms
C#
using Algorithms.Problems.CoinChange; using FluentAssertions; using NUnit.Framework; namespace Algorithms.Tests.Problems.CoinChange.Dynamic { public class GetMinimalNextCoinTests { [Test] public void GetMinimalNextCoinTest_Success() { const int coin = 6; var c...
21
C-Sharp
TheAlgorithms
C#
using System.Linq; using Algorithms.Problems.CoinChange; using FluentAssertions; using NUnit.Framework; namespace Algorithms.Tests.Problems.CoinChange.Dynamic { [TestFixture] public class MakeCoinChangeDynamicTests { [Test] public void MakeCoinChangeDynamicTest_Success() { ...
36
C-Sharp
TheAlgorithms
C#
using System; using System.Linq; using Algorithms.Problems.NQueens; using FluentAssertions; using NUnit.Framework; namespace Algorithms.Tests.Problems.NQueens { public static class BacktrackingNQueensSolverTests { [TestCase(0, 0)] [TestCase(1, 1)] [TestCase(2, 0)] [TestCase(3...
128
C-Sharp
TheAlgorithms
C#
using System; using System.Collections.Generic; using System.Linq; using Algorithms.Problems.StableMarriage; using NUnit.Framework; namespace Algorithms.Tests.Problems.StableMarriage { /// <summary> /// The stable marriage problem (also stable matching problem or SMP) /// is the problem of findi...
54
C-Sharp
TheAlgorithms
C#
using System.Linq; using Algorithms.Search; using NUnit.Framework; using NUnit.Framework.Internal; namespace Algorithms.Tests.Search { public static class BinarySearcherTests { [Test] public static void FindIndex_ItemPresent_IndexCorrect([Random(1, 1000, 100)] int n) { // Ar...
61
C-Sharp
TheAlgorithms
C#
using Algorithms.Search; using System; using System.Collections.Generic; using System.Linq; using NUnit.Framework; using NUnit.Framework.Internal; namespace Algorithms.Tests.Search { public class BoyerMoore_Tests { [Test] public void BoyerMoore_Majority_Finder_Test() { var e...
37
C-Sharp
TheAlgorithms
C#
using Algorithms.Search; using NUnit.Framework; using Utilities.Exceptions; namespace Algorithms.Tests.Search { public static class FastSearcherTests { [Test] public static void FindIndex_ItemPresent_IndexCorrect() { var searcher = new FastSearcher(); var arr ...
83
C-Sharp
TheAlgorithms
C#
using Algorithms.Search; using FluentAssertions; using NUnit.Framework; using System; namespace Algorithms.Tests.Search { public static class FibonacciSearcherTests { [Test] public static void FindIndex_ItemPresent_IndexCorrect([Random(1, 1000, 10)] int n) { // Arranges ...
72
C-Sharp
TheAlgorithms
C#
using System.Linq; using NUnit.Framework; namespace Algorithms.Tests.Search { public static class Helper { public static int[] GetSortedArray(int length) => Enumerable.Range(0, length) .Select(_ => TestContext.CurrentContext.Random.Next(1_000_000)) .OrderBy(x...
33
C-Sharp
TheAlgorithms
C#
using Algorithms.Search; using NUnit.Framework.Internal; using NUnit.Framework; using System; using System.Linq; namespace Algorithms.Tests.Search { public static class InterpolationSearchTests { [Test] public static void FindIndex_ItemPresent_IndexCorrect([Random(1, 1000, 100)] int n) ...
59
C-Sharp
TheAlgorithms
C#
using Algorithms.Search; using NUnit.Framework; using System; using System.Linq; using FluentAssertions; namespace Algorithms.Tests.Search { public class JumpSearcherTests { [Test] public void FindIndex_ItemPresent_ItemCorrect([Random(1, 1000, 100)] int n) { // Arrange ...
69
C-Sharp
TheAlgorithms
C#
using System; using System.Linq; using Algorithms.Search; using NUnit.Framework; using NUnit.Framework.Internal; using Utilities.Exceptions; namespace Algorithms.Tests.Search { public static class LinearSearcherTests { [Test] public static void Find_ItemPresent_ItemCorrect([Random(0, 1_000_0...
73
C-Sharp
TheAlgorithms
C#
using System; using System.Collections.Generic; using System.Linq; using Algorithms.Search; using FluentAssertions; using NUnit.Framework; using NUnit.Framework.Internal; namespace Algorithms.Tests.Search { public static class RecursiveBinarySearcherTests { [Test] public static void FindIndex_I...
78
C-Sharp
TheAlgorithms
C#
using Algorithms.Sequences; using FluentAssertions; using NUnit.Framework; using System; using System.Linq; using System.Numerics; namespace Algorithms.Tests.Sequences; public class AllOnesSequenceTests { [Test] public void First10ElementsCorrect() { var sequence = new AllOnesSequence().Sequence.Ta...
19
C-Sharp
TheAlgorithms
C#
using Algorithms.Sequences; using FluentAssertions; using NUnit.Framework; using System; using System.Linq; using System.Numerics; namespace Algorithms.Tests.Sequences; public class AllThreesSequenceTests { [Test] public void First10ElementsCorrect() { var sequence = new AllThreesSequence().Sequenc...
19
C-Sharp
TheAlgorithms
C#
using Algorithms.Sequences; using FluentAssertions; using NUnit.Framework; using System; using System.Linq; using System.Numerics; namespace Algorithms.Tests.Sequences; public class AllTwosSequenceTests { [Test] public void First10ElementsCorrect() { var sequence = new AllTwosSequence().Sequence.Ta...
19