Download presentation
Presentation is loading. Please wait.
1
Week 1 - Thursday COMP 4100
2
Project 1
3
Assignment 1
4
Unit Testing Examples
5
Prime factors unit testing examples
Consider a Java method with the following signature: int[] primeFactors(int number) This method takes an int value number as a parameter and returns an array containing its unique prime factors Recall that a prime number is a positive integer greater than 1 divisible only by 1 and itself The unique factorization theorem states that any integer greater than 1 can be factored into a list of prime factors and that (ignoring order) these factors are unique Note that the method primeFactors() returns each prime factor only a single time even if it is used multiple times as a factor in the number For example, for the input 60, primeFactors() would return the array consisting of {2, 3, 5} Give testing input, expected output, and the reason for that test
6
Phone format validator unit test examples
Consider a Java method with the following signature: boolean isValidPhone(String number) This method takes a String value and determines whether or not it is a valid North American phone number Valid numbers have the following form: YZX-YXX-XXXX Y must be in the range [2-9] X must be in the range [0-9] Z must be in the range [0-8] The sixth digit cannot be 1 if the fifth is also 1 The dashes may be left out or replaced by spaces Parentheses around the first three digits are allowed The whole number may have an optional prefix of "1", "+1", "1 ", or "1-" (except that "1-" is not allowed when there are parentheses around the first three digits) Give testing input, expected output, and the reason for that test
7
Calculator unit testing examples
Consider a Java class Calculator with the following methods: void enter(double number) void pressAdd() void pressSubtract() void pressMultiply() void pressDivide() double getValue() These methods behave as you would expect equivalent actions punched into a desk calculator would For example, entering the sequence enter(4), pressMultiply(), enter(3) would mean that getValue() would return 12 Give testing input, expected output, and the reason for that test
8
Median unit testing example
Consider a Java method with the following signature: double median(int[] numbers) This method takes an array of int values called numbers as a parameter and returns the median of those values Recall that the median of an odd-length list of numbers is the number whose value comes in the middle if the list were in sorted order Likewise, the median of an even-length list of numbers is the average of the two numbers whose values come in the middle if the list were in sorted order For example, for the input {8, 13, 4}, median() would return 8 Give testing input, expected output, and the reason for that test
9
Housekeeping
10
Form teams! You are not required to be on the same teams as last semester However, you are free to be Once you're on a team, I can add you to the appropriate private GitHub repo
11
Available projects Industrial-grade implementation of text-based video game development tool Interactive website that uses visualization of data to teach the statistics Database and web interface to manage the inventory of the Promise House food pantry Database and web interface for tracking volunteer work and certification at Otterbein Platform-independent mobile app for crypto-currency wallet
12
Upcoming
13
Next time… Gather requirements
14
Reminders Form your teams! Gather requirements for your projects
Get added to the appropriate GitHub repo Pick a topic for the research paper
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.