Advertisement
Guest User

Untitled

a guest
Feb 9th, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.28 KB | None | 0 0
  1.     @Test
  2.     public void test_Power_MaxMax() {
  3.         int a = Integer.MAX_VALUE;
  4.         int b = Integer.MAX_VALUE;
  5.         int expected = (int)Math.pow(Integer.MAX_VALUE, Integer.MAX_VALUE) % (int)(Math.pow(2, 31));
  6.         //int expected = Integer.MAX_VALUE ^ (2 ^ 31) % (2 ^ 31);
  7.         String info = "Два максимальных целочисленных.";
  8.  
  9.         assertEquals(info, expected, obj.power(a, b));
  10.     }
  11.  
  12.     @Test
  13.     public void test_Power_ZeroMax() {
  14.         int a = 0;
  15.         int b = Integer.MAX_VALUE;
  16.         int expected = 0;
  17.         String info = "Возводим нуль в MAX_VALUE.";
  18.  
  19.         assertEquals(info, expected, obj.power(a, b));
  20.     }
  21.  
  22.     @Test
  23.     public void test_Power_MaxZero() {
  24.         int a = Integer.MAX_VALUE;
  25.         int b = 0;
  26.         int expected = 1;
  27.         String info = "Возводим MAX_VALUE в нуль.";
  28.  
  29.         assertEquals(info, expected, obj.power(a, b));
  30.     }
  31.  
  32.     @Test
  33.     public void test_Power_OverflowMaxInt() {
  34.         int a = Integer.MAX_VALUE;
  35.         int b = 2;
  36.         int expected = (int)((Math.pow(Integer.MAX_VALUE, 2)) % (Math.pow(2, 31)));
  37.         String info = "Возводим MAX_VALUE в степень 2.";
  38.  
  39.         assertEquals(info, expected, obj.power(a, b));
  40.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement