// Path: lib/src/main/java/hrv/lib/algorithm/search/FindIndexOfClosestValueSorted.java
// public class FindIndexOfClosestValueSorted {
// 
//     /**
//      * Finds the index with the value whose distance
//      * to the given {@code value} is the shortest
//      *
//      * @param array Sorted array to search the index in
//      * @param value value to which the index of the value with the shortest distance is searched to
//      * @return index with the shortest distance to {@code value}
//      */
//     public int findClosestIndexInSortedArray(double[] array, double value) {
//         //Set closest index to last index
//         int closestIndex = array.length;
// 
//         //Set closest distance to maximum distance
//         double closestDistance = Math.abs(array[array.length - 1] - array[0]);
// 
//         //find index with closest distance
//         for (var i = 0; i < array.length; i++) {
//             double distance = Math.abs(array[i] - value);
// 
//             if (distance < closestDistance) {
//                 closestIndex = i;
//                 closestDistance = distance;
//             }
//         }
// 
//         return closestIndex;
//     }
// }


import hrv.lib.algorithm.search.FindIndexOfClosestValueSorted;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
package hrv.lib.algorithm;



class FindIndexOfClosestValueSortedTest {

	@Test
	void testFindIndexOfClosestValueSorted() {
		
		double[] array = new double[] {2,3,4,5,6,7,8,9,100,101};
		
// Path: lib/src/main/java/hrv/lib/algorithm/search/FindIndexOfClosestValueSorted.java
// public class FindIndexOfClosestValueSorted {
// 
//     /**
//      * Finds the index with the value whose distance
//      * to the given {@code value} is the shortest
//      *
//      * @param array Sorted array to search the index in
//      * @param value value to which the index of the value with the shortest distance is searched to
//      * @return index with the shortest distance to {@code value}
//      */
//     public int findClosestIndexInSortedArray(double[] array, double value) {
//         //Set closest index to last index
//         int closestIndex = array.length;
// 
//         //Set closest distance to maximum distance
//         double closestDistance = Math.abs(array[array.length - 1] - array[0]);
// 
//         //find index with closest distance
//         for (var i = 0; i < array.length; i++) {
//             double distance = Math.abs(array[i] - value);
// 
//             if (distance < closestDistance) {
//                 closestIndex = i;
//                 closestDistance = distance;
//             }
//         }
// 
//         return closestIndex;
//     }
// }


// Path: lib/src/test/java/hrv/lib/algorithm/FindIndexOfClosestValueSortedTest.java
import hrv.lib.algorithm.search.FindIndexOfClosestValueSorted;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;

package hrv.lib.algorithm;



class FindIndexOfClosestValueSortedTest {

	@Test
	void testFindIndexOfClosestValueSorted() {
		
		double[] array = new double[] {2,3,4,5,6,7,8,9,100,101};
		
		FindIndexOfClosestValueSorted indexFinder = new FindIndexOfClosestValueSorted();