123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235 |
-
-
- import org.junit.Assert;
- import org.junit.Test;
-
- public class NumberUtilitiesTest {
- @Test
- public void testGetRange1A() {
- // : Given
- String expected = "0123456789";
- int stop = 11;
-
- // : When
- String actual = NumberUtilities.getRange(stop);
-
- // : Then
- Assert.assertEquals(expected, actual);
- }
-
- @Test
- public void testGetRange2A() {
- // : Given
- String expected = "01234";
- int stop = 5;
-
- // : When
- String actual = NumberUtilities.getRange(stop);
-
- // : Then
- Assert.assertEquals(expected, actual);
- }
-
- @Test
- public void testGetRange3A() {
- // : Given
- String expected = "012345678910111213141516171819";
- int stop = 20;
-
- // : When
- String actual = NumberUtilities.getRange(stop);
-
- // : Then
- Assert.assertEquals(expected, actual);
- }
-
-
-
-
-
-
-
-
-
-
-
-
- @Test
- public void testGetRange1B() {
- // : Given
- String expected = "5678910111213141516171819";
- int start = 5;
- int stop = 20;
-
- // : When
- String actual = NumberUtilities.getRange(start, stop);
-
- // : Then
- Assert.assertEquals(expected, actual);
- }
-
-
- @Test
- public void testGetRange2B() {
- // : Given
- String expected = "101112131415161718192021222324";
- int start = 10;
- int stop = 25;
-
- // : When
- String actual = NumberUtilities.getRange(start, stop);
-
- // : Then
- Assert.assertEquals(expected, actual);
- }
-
-
- @Test
- public void testGetRange3B() {
- // : Given
- String expected = "100101103104105106107108109";
- int start = 100;
- int stop = 110;
-
- // : When
- String actual = NumberUtilities.getRange(start, stop);
-
- // : Then
- Assert.assertEquals(expected, actual);
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
- @Test
- public void testGetRange1C() {
- // : Given
- String expected = "51015";
- int start = 5;
- int stop = 20;
- int step = 5;
-
- // : When
- String actual = NumberUtilities.getRange(start, stop, step);
-
- // : Then
- Assert.assertEquals(expected, actual);
- }
-
-
- @Test
- public void testGetRange2C() {
- // : Given
- String expected = "012345678910111213141516171819";
- int start = 0;
- int stop = 20;
- int step = 1;
-
- // : When
- String actual = NumberUtilities.getRange(start, stop, step);
-
- // : Then
- Assert.assertEquals(expected, actual);
- }
-
-
- @Test
- public void testGetRange3C() {
- // : Given
- String expected = "0246810";
- int start = 0;
- int stop = 11;
- int step = 2;
-
- // : When
- String actual = NumberUtilities.getRange(start, stop, step);
-
- // : Then
- Assert.assertEquals(expected, actual);
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- @Test
- public void testGetEvenNumbers() {
- // : Given
- String expected = "5791113151719";
- int start = 5;
- int stop = 20;
-
- // : When
- String actual = NumberUtilities.getEvenNumbers(start, stop);
-
- // : Then
- Assert.assertEquals(expected, actual);
- }
-
- @Test
- public void testGetOddNumbers() {
- // : Given
- String expected = "681012141618";
- int start = 5;
- int stop = 20;
- int step = 5;
-
- // : When
- String actual = NumberUtilities.getOddNumbers(start, stop);
-
- // : Then
- Assert.assertEquals(expected, actual);
- }
-
-
-
- @Test
- public void testGetSquareNumbers() {
- // : Given
- String expected = "25100225";
- int start = 5;
- int stop = 20;
- int step = 5;
-
- // : When
- String actual = NumberUtilities.getSquareNumbers(start, stop, step);
-
- // : Then
- Assert.assertEquals(expected, actual);
- }
-
-
- @Test
- public void testGetExponentiationNumbers() {
- // : Given
- String expected = "25100225";
- int start = 5;
- int stop = 20;
- int step = 5;
- int exponent = 2;
-
- // : When
- String actual = NumberUtilities.getExponentiations(start, stop, step, exponent);
-
- Assert.assertEquals(expected, actual);
- }
- }
|