Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Test
- public void test_Power_MaxMax() {
- int a = Integer.MAX_VALUE;
- int b = Integer.MAX_VALUE;
- int expected = (int)Math.pow(Integer.MAX_VALUE, Integer.MAX_VALUE) % (int)(Math.pow(2, 31));
- //int expected = Integer.MAX_VALUE ^ (2 ^ 31) % (2 ^ 31);
- String info = "Два максимальных целочисленных.";
- assertEquals(info, expected, obj.power(a, b));
- }
- @Test
- public void test_Power_ZeroMax() {
- int a = 0;
- int b = Integer.MAX_VALUE;
- int expected = 0;
- String info = "Возводим нуль в MAX_VALUE.";
- assertEquals(info, expected, obj.power(a, b));
- }
- @Test
- public void test_Power_MaxZero() {
- int a = Integer.MAX_VALUE;
- int b = 0;
- int expected = 1;
- String info = "Возводим MAX_VALUE в нуль.";
- assertEquals(info, expected, obj.power(a, b));
- }
- @Test
- public void test_Power_OverflowMaxInt() {
- int a = Integer.MAX_VALUE;
- int b = 2;
- int expected = (int)((Math.pow(Integer.MAX_VALUE, 2)) % (Math.pow(2, 31)));
- String info = "Возводим MAX_VALUE в степень 2.";
- assertEquals(info, expected, obj.power(a, b));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement