Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

데블스캠프2011/다섯째날/HowToWriteCodeWell/임상현,서민관: Difference between revisions

From ZeroWiki
imported>lim410
No edit summary
 
imported>lim410
No edit summary
Line 1: Line 1:
import static org.junit.Assert.*;
import static org.junit.Assert.*;
 
import java.util.Timer;
import java.util.Timer;
 
import org.junit.After;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.Test;
 
 
public class testTest {
public class testTest {
 
private Elev el1;
private Elev el1;
private Elev el2;
private Elev el2;
 
@Before
@Before
public void setUp() throws Exception {
public void setUp() throws Exception {
el1 = new Elev(10,-2);
el1 = new Elev(10,-2);
el2 = new Elev(-10,20);
el2 = new Elev(-10,20);
}
}
 
@After
@After
public void tearDown() throws Exception {
public void tearDown() throws Exception {
}
}
 
@Test
@Test
public void testConstructor1() {
public void testConstructor1() {
Elev el3 = new Elev(10,-2);
Elev el3 = new Elev(10,-2);
assertEquals("UP", el3.direction);
assertEquals("UP", el3.direction);
assertEquals(1, el3.currentFloor);
assertEquals(1, el3.currentFloor);
assertEquals(0, el3.Turn);
assertEquals(0, el3.Turn);
assertEquals(10, el3.maxFloor);
assertEquals(10, el3.maxFloor);
assertEquals(-2, el3.minFloor);
assertEquals(-2, el3.minFloor);
}
}
@Test
@Test
public void testConstructor2() {
public void testConstructor2() {
Elev el3 = new Elev(-2,10);
Elev el3 = new Elev(-2,10);
assertEquals("UP", el3.direction);
assertEquals("UP", el3.direction);
assertEquals(1, el3.currentFloor);
assertEquals(1, el3.currentFloor);
assertEquals(0, el3.Turn);
assertEquals(0, el3.Turn);
assertEquals(10, el3.maxFloor);
assertEquals(10, el3.maxFloor);
assertEquals(-2, el3.minFloor);
assertEquals(-2, el3.minFloor);
}
}
@Test
@Test
public void testConstructor3() {
public void testConstructor3() {
Elev el3 = new Elev(-2,-20);
Elev el3 = new Elev(-2,-20);
assertEquals("DOWN", el3.direction);
assertEquals("DOWN", el3.direction);
assertEquals(-2, el3.currentFloor);
assertEquals(-2, el3.currentFloor);
assertEquals(0, el3.Turn);
assertEquals(0, el3.Turn);
assertEquals(-2, el3.maxFloor);
assertEquals(-2, el3.maxFloor);
assertEquals(-20, el3.minFloor);
assertEquals(-20, el3.minFloor);
}
}
@Test
@Test
public void testConstructor4() {
public void testConstructor4() {
Elev el3 = new Elev(3,30);
Elev el3 = new Elev(3,30);
assertEquals("UP", el3.direction);
assertEquals("UP", el3.direction);
assertEquals(3, el3.currentFloor);
assertEquals(3, el3.currentFloor);
assertEquals(0, el3.Turn);
assertEquals(0, el3.Turn);
assertEquals(30, el3.maxFloor);
assertEquals(30, el3.maxFloor);
assertEquals(3, el3.minFloor);
assertEquals(3, el3.minFloor);
}
}
 
@Test
@Test
public void testgoTo1() throws Exception {
public void testgoTo1() throws Exception {
el1.goTo(4);
el1.goTo(4);
assertEquals(3, el1.Turn);
assertEquals(3, el1.Turn);
assertEquals(4, el1.currentFloor);
assertEquals(4, el1.currentFloor);
}
}
@Test(expected = Exception.class)
@Test(expected = Exception.class)
public void testgoTo2() throws Exception {
public void testgoTo2() throws Exception {
el1.goTo(44);
el1.goTo(44);
assertEquals(1, el1.currentFloor);
assertEquals(1, el1.currentFloor);
}
}
 
@Test(expected = Exception.class)
@Test(expected = Exception.class)
public void testgoTo3() throws Exception {
public void testgoTo3() throws Exception {
el1.goTo(-39);
el1.goTo(-39);
assertEquals(1, el1.currentFloor);
assertEquals(1, el1.currentFloor);
}
}
 
@Test
@Test
public void testupTo1() throws Exception {
public void testupTo1() throws Exception {
el1.upTo(5);
el1.upTo(5);
assertEquals(4, el1.Turn);
assertEquals(4, el1.Turn);
assertEquals(5, el1.currentFloor);
assertEquals(5, el1.currentFloor);
}
}
 
@Test(expected = Exception.class)
@Test(expected = Exception.class)
public void testupTo2() throws Exception {
public void testupTo2() throws Exception {
el1.upTo(30);
el1.upTo(30);
}
}
 
@Test(expected = Exception.class)
@Test(expected = Exception.class)
public void testupTo3() throws Exception {
public void testupTo3() throws Exception {
el1.upTo(-39);
el1.upTo(-39);
}
}
@Test(expected = Exception.class)
@Test(expected = Exception.class)
public void testupTo4() throws Exception {
public void testupTo4() throws Exception {
el1.upTo(0);
el1.upTo(0);
}
}
@Test
@Test
public void testdownTo1() throws Exception {
public void testdownTo1() throws Exception {
el1.downTo(5);
el1.downTo(5);
assertEquals(4, el1.Turn);
assertEquals(4, el1.Turn);
assertEquals(5, el1.currentFloor);
assertEquals(5, el1.currentFloor);
}
}
 
@Test(expected = Exception.class)
@Test(expected = Exception.class)
public void testdownTo2() throws Exception {
public void testdownTo2() throws Exception {
el1.downTo(30);
el1.downTo(30);
}
}
 
@Test(expected = Exception.class)
@Test(expected = Exception.class)
public void testdownTo3() throws Exception {
public void testdownTo3() throws Exception {
el1.downTo(-39);
el1.downTo(-39);
}
}
@Test(expected = Exception.class)
@Test(expected = Exception.class)
public void testdownTo4() throws Exception {
public void testdownTo4() throws Exception {
el1.downTo(0);
el1.downTo(0);
}
}
@Test
@Test
public void testpush1() throws Exception {
public void testpush1() throws Exception {
el1.push(5);
el1.push(5);
assertEquals(4, el1.Turn);
assertEquals(4, el1.Turn);
assertEquals(5, el1.currentFloor);
assertEquals(5, el1.currentFloor);
}
}
 
@Test(expected = Exception.class)
@Test(expected = Exception.class)
public void testpush2() throws Exception {
public void testpush2() throws Exception {
el1.push(30);
el1.push(30);
}
}
 
@Test(expected = Exception.class)
@Test(expected = Exception.class)
public void testpush3() throws Exception {
public void testpush3() throws Exception {
el1.push(-39);
el1.push(-39);
}
}
@Test(expected = Exception.class)
@Test(expected = Exception.class)
public void testpush4() throws Exception {
public void testpush4() throws Exception {
el1.push(0);
el1.push(0);
}
}
@Test
@Test
public void testcase1() {
public void testcase1() {
assertEquals(1, el1.currentFloor);
assertEquals(1, el1.currentFloor);
}
}
 
}
}



Revision as of 19:02, 1 July 2011

import static org.junit.Assert.*;

import java.util.Timer;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;


public class testTest {

	private Elev el1;
	private Elev el2;

	@Before
	public void setUp() throws Exception {
		el1 = new Elev(10,-2);
		el2 = new Elev(-10,20);
	}

	@After
	public void tearDown() throws Exception {
		
	}

	@Test
	public void testConstructor1() {
		Elev el3 = new Elev(10,-2);
		assertEquals("UP", el3.direction);
		assertEquals(1, el3.currentFloor);
		assertEquals(0, el3.Turn);
		assertEquals(10, el3.maxFloor);
		assertEquals(-2, el3.minFloor);
	}
	
	@Test
	public void testConstructor2() {
		Elev el3 = new Elev(-2,10);
		assertEquals("UP", el3.direction);
		assertEquals(1, el3.currentFloor);
		assertEquals(0, el3.Turn);
		assertEquals(10, el3.maxFloor);
		assertEquals(-2, el3.minFloor);		
	}
	
	@Test
	public void testConstructor3() {
		Elev el3 = new Elev(-2,-20);
		assertEquals("DOWN", el3.direction);
		assertEquals(-2, el3.currentFloor);
		assertEquals(0, el3.Turn);
		assertEquals(-2, el3.maxFloor);
		assertEquals(-20, el3.minFloor);	
		
	}
	
	@Test
	public void testConstructor4() {
		Elev el3 = new Elev(3,30);
		assertEquals("UP", el3.direction);
		assertEquals(3, el3.currentFloor);
		assertEquals(0, el3.Turn);
		assertEquals(30, el3.maxFloor);
		assertEquals(3, el3.minFloor);
		
	}
	

	@Test
	public void testgoTo1() throws Exception {
		el1.goTo(4);
		assertEquals(3, el1.Turn);
		assertEquals(4, el1.currentFloor);
	}
	
	@Test(expected = Exception.class)
	public void testgoTo2() throws Exception {
		el1.goTo(44);
		assertEquals(1, el1.currentFloor);
	}

	@Test(expected = Exception.class)
	public void testgoTo3() throws Exception {
		el1.goTo(-39);
		assertEquals(1, el1.currentFloor);
	}
	

	@Test
	public void testupTo1() throws Exception {
		el1.upTo(5);
		assertEquals(4, el1.Turn);
		assertEquals(5, el1.currentFloor);
	}

	@Test(expected = Exception.class)
	public void testupTo2() throws Exception {
		el1.upTo(30);
	}

	@Test(expected = Exception.class)
	public void testupTo3() throws Exception {
		el1.upTo(-39);
	}
	
	@Test(expected = Exception.class)
	public void testupTo4() throws Exception {
		el1.upTo(0);
	}
	
	@Test
	public void testdownTo1() throws Exception {
		el1.downTo(5);
		assertEquals(4, el1.Turn);
		assertEquals(5, el1.currentFloor);
	}

	@Test(expected = Exception.class)
	public void testdownTo2() throws Exception {
		el1.downTo(30);
	}

	@Test(expected = Exception.class)
	public void testdownTo3() throws Exception {
		el1.downTo(-39);
	}
	@Test(expected = Exception.class)
	public void testdownTo4() throws Exception {
		el1.downTo(0);
	}
	
	@Test
	public void testpush1() throws Exception {
		el1.push(5);
		assertEquals(4, el1.Turn);
		assertEquals(5, el1.currentFloor);
	}

	@Test(expected = Exception.class)
	public void testpush2() throws Exception {
		el1.push(30);
	}

	@Test(expected = Exception.class)
	public void testpush3() throws Exception {
		el1.push(-39);
	}
	@Test(expected = Exception.class)
	public void testpush4() throws Exception {
		el1.push(0);
	}
	
	@Test
	public void testcase1() {
		assertEquals(1, el1.currentFloor);
	}
	

	
}