ЛР2 добавление теста

This commit is contained in:
ityurner02@mail.ru 2023-02-28 11:36:07 +04:00
parent aac82d37ee
commit 46ecf5eac3
3 changed files with 9 additions and 7 deletions

View File

@ -2,8 +2,6 @@ package ru.ulstu.is.lab1;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@SpringBootApplication

View File

@ -17,12 +17,10 @@ public class MethodInt implements IMethod<Integer>{
}
public Integer Comparison(Integer first, Integer second) {
int num1 = first;
int num2 = second;
if (num1 >= num2){
return num1;
if (first >= second){
return first;
}else{
return num2;
return second;
}
}
}

View File

@ -1,5 +1,6 @@
package ru.ulstu.is.lab1;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import ru.ulstu.is.lab1.speaker.service.MethodService;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
@ -55,4 +56,9 @@ class Lab1ApplicationTests {
final String res = methodService.Com("846734", "312", "string");
Assertions.assertEquals("846734", res);
}
@Test
void testNumberFormatException() {
final String res = methodService.Sum("п", 3, "int");
Assertions.assertThrows(NumberFormatException.class, () -> methodService.Sum(5, 3, "int"));
}
}