Introduction
This time I'm working on creating a minor unit test for a algorithm-gathering repo. algorithmUse is a repo created for the purpose to embark on Data Structures and Algorithm. This repo contains multiple popular algorithms written in various languages.
What did I do?
To encourage people to get involved to open source. The owner of the repo open an issue in which requested contribution to create unit tests for their algorithms.
How did I do
I, myself, also want to contribute. Therefore, I started to write a test for their binary search algorithm. My test is basically based on:
- Return -1 if an array is empty
- Return -1 if the to-be-found element is even in an odd array
- Return the 0 if the element is found in the first position of an sorted array
- Return the index of an element in an array.
- Return middle - 1 if the element is found in the middle of the array.
Conclusion
- Writing test helps us to have big picture when it comes to designing an algorithm.
- You can also check my contribution at here
Top comments (0)