CourseUtilities.java

1
package edu.ucsb.cs156.courses.utilities;
2
3
/**
4
 * static utility methods for dealing with courses
5
 */
6
public class CourseUtilities {
7
8
    // Utility class; this allows jacoco to be satisified that constructors are covered.
9
    private CourseUtilities() {} 
10
11
    /**
12
     * Given a subject area and course number, return a course id that is formatted
13
     * in the precise way that course numbers are formatted in UCSB's GOLD system.
14
     * 
15
     * That format has the subject area left justified in an 8 character field,
16
     * followed by the course number right justified in a 3 character field,
17
     * followed
18
     * by the suffix (if any) left justified in a 2 character field.
19
     * 
20
     * Examples: (the <code>1234567812312</code> line is there to show the spacing.)
21
     * 
22
     * <pre>
23
     * 1234567812312
24
     * CMPSC   130A
25
     * CMPSC     5JA
26
     * CMPSC    24
27
     * </pre>
28
     * 
29
     * @param subjectArea  subject area, such as CMPSC
30
     * @param courseNumber course number, such as 130A
31
     * @return formatted course number
32
     */
33
    public static String makeFormattedCourseId(String subjectArea, String courseNumber) {
34
        String[] nums = courseNumber.split("[a-zA-Z]+");
35
        String[] suffs = courseNumber.split("[0-9]+");
36
        String result = "";
37 2 1. makeFormattedCourseId : changed conditional boundary → KILLED
2. makeFormattedCourseId : negated conditional → KILLED
        if (suffs.length < 2) { // no suffix
38
            result = String.format("%-8s", subjectArea) // 'CMPSC '
39
                    + String.format("%3s", nums[0]) // ' 8'
40
            ;
41
        } else {
42
            result = String.format("%-8s", subjectArea) // 'CMPSC '
43
                    + String.format("%3s", nums[0]) // ' 8'
44
                    + String.format("%-2s", suffs[1]) // 'A '
45
            ;
46
        }
47 1 1. makeFormattedCourseId : replaced return value with "" for edu/ucsb/cs156/courses/utilities/CourseUtilities::makeFormattedCourseId → KILLED
        return result.trim();
48
    }
49
}

Mutations

37

1.1
Location : makeFormattedCourseId
Killed by : edu.ucsb.cs156.courses.utilities.CourseUtilitiesTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.courses.utilities.CourseUtilitiesTests]/[method:test_makeFormattedCourseId_CMPSC_5A()]
changed conditional boundary → KILLED

2.2
Location : makeFormattedCourseId
Killed by : edu.ucsb.cs156.courses.utilities.CourseUtilitiesTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.courses.utilities.CourseUtilitiesTests]/[method:test_makeFormattedCourseId_CMPSC_5A()]
negated conditional → KILLED

47

1.1
Location : makeFormattedCourseId
Killed by : edu.ucsb.cs156.courses.utilities.CourseUtilitiesTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.courses.utilities.CourseUtilitiesTests]/[method:test_makeFormattedCourseId_CMPSC_5A()]
replaced return value with "" for edu/ucsb/cs156/courses/utilities/CourseUtilities::makeFormattedCourseId → KILLED

Active mutators

Tests examined


Report generated by PIT 1.7.3