0% found this document useful (0 votes)
153 views2 pages

Week 4 Test

This document contains test cases for methods that find the maximum of two integers, minimum of an integer array, and calculate BMI based on weight and height. There are test cases for each method that validate expected outputs against actual outputs from calling the methods.

Uploaded by

Duy Quyền
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
153 views2 pages

Week 4 Test

This document contains test cases for methods that find the maximum of two integers, minimum of an integer array, and calculate BMI based on weight and height. There are test cases for each method that validate expected outputs against actual outputs from calling the methods.

Uploaded by

Duy Quyền
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

import org.junit.

Assert;
import org.junit.Test;

public class Week4Test {


@Test
public void testMax2Int1() {
final int expected = 5;
final int actual = Week4.max2Int(-10, 5);
Assert.assertEquals(expected, actual);
}

@Test
public void testMax2Int2() {
final int expected = 10;
final int actual = Week4.max2Int(10, 5);
Assert.assertEquals(expected, actual);
}

@Test
public void testMax2Int3() {
final int expected = 10;
final int actual = Week4.max2Int(10, -5);
Assert.assertEquals(expected, actual);
}

@Test
public void testMax2Int4() {
final int expected = 20;
final int actual = Week4.max2Int(3, 20);
Assert.assertEquals(expected, actual);

@Test
public void testMax2Int5() {
final int expected = 8;
final int actual = Week4.max2Int(8, 4);
Assert.assertEquals(expected, actual);
}

@Test
public void testMinArray1() {
final int expected = 2;
int[] arr = {2, 4, 5, 6};
final int actual = Week4.minArray(arr);
Assert.assertEquals(expected, actual);
}

@Test
public void testMinArray2() {
final int expected = 1;
int[] arr = {3, 23, 1, 43, 67};
final int actual = Week4.minArray(arr);
Assert.assertEquals(expected, actual);
}

@Test
public void testMinArray3() {
final int expected = 23;
int[] arr = {74, 54, 34, 23, 63};
final int actual = Week4.minArray(arr);
Assert.assertEquals(expected, actual);
}

@Test
public void testMinArray4() {
final int expected = 5;
int[] arr = {12, 67, 7, 5, 65};
final int actual = Week4.minArray(arr);
Assert.assertEquals(expected, actual);
}

@Test
public void testMinArray5() {
final int expected = 2;
int[] arr = {2, 4, 5, 6};
final int actual = Week4.minArray(arr);
Assert.assertEquals(expected, actual);
}

@Test
public void testCalculateBmi1() {
final String expected = "Bình thường";
final String actual = Week4.calculateBMI(56, 1.6);
Assert.assertEquals(expected, actual);
}

@Test
public void testCalculateBmi2() {
final String expected = "Thiếu cân";
final String actual = Week4.calculateBMI(46, 1.6);
Assert.assertEquals(expected, actual);
}

@Test
public void testCalculateBmi3() {
final String expected = "Bình thường";
final String actual = Week4.calculateBMI(56, 1.7);
Assert.assertEquals(expected, actual);
}

@Test
public void testCalculateBmi4() {
final String expected = "Thừa cân";
final String actual = Week4.calculateBMI(60, 1.6);
Assert.assertEquals(expected, actual);
}

@Test
public void testCalculateBmi5() {
final String expected = "Béo phì";
final String actual = Week4.calculateBMI(80, 1.75);
Assert.assertEquals(expected, actual);
}
}

You might also like