forked from mpmenne/launchcode-java-class
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathStudentAndCourseTest.java
More file actions
37 lines (30 loc) · 891 Bytes
/
Copy pathStudentAndCourseTest.java
File metadata and controls
37 lines (30 loc) · 891 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import static org.junit.Assert.*;
import org.junit.Test;
import junit.framework.TestCase;
/**
* JUnit tests for Student and Course
* @author dshook
*
*/
public class StudentAndCourseTest extends TestCase {
@Test
public void testStudentInit() {
Student s = new Student("Doug", "Shook", 111111);
assertEquals("Doug Shook", s.getName());
assertEquals(111111, s.getStudentID());
//No credits, no GPA
assertEquals(0.0, s.getGPA());
assertEquals(0, s.getCredits());
//Generate some random students, and test
for (int i = 0; i < 20; ++i) {
double a = (Math.random() * 5000);
double b = (Math.random() * 5000);
int c = (int)(Math.random() * 5000);
Student s3 = new Student("" + a, "" + b, c);
assertEquals(a + " " + b, s3.getName());
assertEquals(0.0, s3.getGPA());
assertEquals(0, s3.getCredits());
}
}
//More tests should go here
}