BGC Tools
Public Member Functions
BGC.Tests.BinarySearchTest Class Reference

Public Member Functions

void TestBinarySearch ()
 

Detailed Description

Definition at line 9 of file BinarySearchTest.cs.

Member Function Documentation

◆ TestBinarySearch()

void BGC.Tests.BinarySearchTest.TestBinarySearch ( )
inline

Definition at line 12 of file BinarySearchTest.cs.

13  {
14  float[] testArray = new float[] { 2f, 4f, 6f, 7f, 8f, 9f, 10f, 12f, 16f, 17f, 80f };
15 
16  float[] inputValues = new float[]
17  { 1f, 2f, 2.1f, 4f, 4.1f, 5.99f, 6f, 8.5f, 16.1f, 17f, 50f, 80f, 81f };
18  int[] outputValues = new int[]
19  { -1, 0, 0, 1, 1, 1, 2, 4, 8, 9, 9, 10, 10 };
20 
21  for (int i = 0; i < inputValues.Length; i++)
22  {
23  Assert.IsTrue(testArray.BinarySearchLowerBound(inputValues[i]) == outputValues[i],
24  $"Failed Binary Search Test {i}. " +
25  $"Expected {outputValues[i]}, " +
26  $"Found {testArray.BinarySearchLowerBound(inputValues[i])}");
27  }
28  }

The documentation for this class was generated from the following file: