BAEL-1305: A Simple Guide to Java Loops. (#3133)

This commit is contained in:
Shouvik Bhattacharya
2017-11-27 03:36:18 +05:30
committed by Grzegorz Piwowarek
parent 1b0f99a2d8
commit 29bfac0e95
2 changed files with 80 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
package com.baeldung.loops;
import org.junit.Assert;
import org.junit.Test;
public class WhenUsingLoops {
private LoopsInJava loops = new LoopsInJava();
@Test
public void shouldRunForLoop() {
int[] expected = { 0, 1, 2, 3, 4 };
int[] actual = loops.simple_for_loop();
Assert.assertArrayEquals(expected, actual);
}
@Test
public void shouldRunEnhancedForeachLoop() {
int[] expected = { 0, 1, 2, 3, 4 };
int[] actual = loops.enhanced_for_each_loop();
Assert.assertArrayEquals(expected, actual);
}
@Test
public void shouldRunWhileLoop() {
int[] expected = { 0, 1, 2, 3, 4 };
int[] actual = loops.while_loop();
Assert.assertArrayEquals(expected, actual);
}
@Test
public void shouldRunDoWhileLoop() {
int[] expected = { 0, 1, 2, 3, 4 };
int[] actual = loops.do_while_loop();
Assert.assertArrayEquals(expected, actual);
}
}