test1_patients.java

来自「A system to manage patients of an hospit」· Java 代码 · 共 68 行

JAVA
68
字号
import junit.framework.TestCase;import hospital.*;public class Test1_Patients extends TestCase {	public Test1_Patients(String arg0) {		super(arg0);	}		public void testAdd() throws NoSuchPatient {		Hospital h = new Hospital();		String ssn = "THEPID12I99F181K";		String first = "Giova";		String last = "Reds";		h.addPatient(first, last, ssn);		Patient p = h.getPatient(ssn);		assertEquals(first, p.getFirst());		assertEquals(last, p.getLast());	}		public void testNotFoundEmpty() {		Hospital h = new Hospital();		String ssn = "THEPID12I99F181K";		try {			Patient p = h.getPatient(ssn);			assertEquals(p, null);		} catch (NoSuchPatient e) {			assertTrue(true);			}	}//? this test is passing	public void testAddNull() {		Hospital h = new Hospital();		h.addPatient(null, null, null);	}		public void testNotFound() {		Hospital h = new Hospital();				String ssn = "THEPID12I99F181K";		String first = "Giova";		String last = "Reds";				h.addPatient(first, last, ssn);				try {			Person p = h.getPatient(ssn + "_");			assertEquals(p, null);		} catch (NoSuchPatient e) {			assertTrue(true); //?			}	}		public void testInsertTwice() throws NoSuchPatient {				Hospital h = new Hospital();				String ssn = "THEPID12I99F181K";		String first = "Giova";		String last = "Reds";				h.addPatient(first+"X", last+"Y", ssn);		h.addPatient(first, last, ssn);				Person p = h.getPatient(ssn);		assertEquals(first, p.getFirst());	}}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?