How can i check if a variable is inside a range of numbers in a parameterized JUnit Test
<p>I am creating a worksheet about language models for a course called "Information Retrieval". The students should be able to check if their code produces the correct answers so i set up a couple of Junit Tests which checks a number of cases. Because i wanted to include multiple test-cases i decided to use parameterized Junit Tests. (I followed this example: <a href="http://www.mkyong.com/unittest/junit-4-tutorial-6-parameterized-test/" rel="nofollow">http://www.mkyong.com/unittest/junit-4-tutorial-6-parameterized-test/</a>)
I want to test a function which returns a float which can be <strong>within</strong> a range of numbers. If I would be testing two floats i would be able to use</p>

<p><code>assertEquals(float expected, float actual, float delta)</code></p>

<p>where the delta is the range.
But because I am using parameterized Tests I have to work with Objects</p>

<p><code>assertEquals(Object expected, Object actual)</code></p>

<p>These Objects are Lists which contain Floats, but in the Code they are just Objects so Solutions like these do not work:</p>

<p><code>assertEquals(Object expected, Object actual, float delta)</code> (this method does not exist)</p>

<p><code>assertTrue(Math.abs(Object expected - Object actual)&lt;ERROR_MARGIN)</code> (Operator '-' undefined for Object)</p>