Advertisement
Guest User

Ben's test cases

a guest
Jan 29th, 2015
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 12.41 KB | None | 0 0
  1.         //test 1, hammingDistance
  2.         int[] list1 = {1, 2, 3, 4, 5, 6, 7, 8, 9};
  3.         int[] list2 = {1, 2, 3, 4, 5, 6, 7, 8, 9};
  4.         int expected = 0;
  5.         int actual = CodeCamp.hammingDistance(list1,list2);
  6.         System.out.println("Test 1 hamming distance: expected value: " +
  7.                 expected + ", actual value: " + actual);
  8.         if( expected == actual )          
  9.             System.out.println(" passed test, hamming distance");
  10.         else
  11.             System.out.println(" ***** FAILED ***** test, hamming distance");
  12.         System.out.println();
  13.        
  14.         //test 2, hammingDistance
  15.         list1 = new int[] {1, 2, 3, 4, 5, 6, 7, 8};
  16.         list2 = new int[] {2, 3, 4, 5, 5, 6, 9, 8};
  17.         expected = 5;
  18.         actual = CodeCamp.hammingDistance(list1,list2);
  19.         System.out.println("Test 2 hamming distance: expected value: " +
  20.                 expected + ", actual value: " + actual);
  21.         if( expected == actual )          
  22.             System.out.println(" passed test, hamming distance");
  23.         else
  24.             System.out.println(" ***** FAILED ***** test, hamming distance");
  25.        
  26.         //test 3, isPermutation
  27.         int[] a = {5, 5};
  28.         int[] b = {2, 1, 3};
  29.         boolean expectedBool = false;
  30.         boolean actualBool = CodeCamp.isPermutation(a,b);
  31.         System.out.println(newline + "Test 3 isPermutation: expected value: "
  32.                 + expectedBool + ", actual value: " + actualBool);
  33.         if ( expectedBool == actualBool )
  34.             System.out.println(" passed test, isPermutation");
  35.         else
  36.             System.out.println(" ***** FAILED ***** test, isPermutation");
  37.        
  38.         //test 4, isPermutation
  39.         a = new int[]{1,1,1,1,1};
  40.         b = new int[]{1,1,1,1,1};
  41.         expectedBool = true;
  42.         actualBool = CodeCamp.isPermutation(a,b);
  43.         System.out.println(newline + "Test 4 isPermutation: expected value: "
  44.                 + expectedBool + ", actual value: " + actualBool);
  45.         if ( expectedBool == actualBool )
  46.             System.out.println(" passed test, isPermutation");
  47.         else
  48.             System.out.println(" ***** FAILED ***** test, isPermutation");
  49.        
  50.         //test 5, isPermutation
  51.         a = new int[]{10,30000000,500000,129219129,12111,3536};
  52.         b = new int[]{30000000,500000,12111,3536,10,129219129};
  53.         expectedBool = true;
  54.         actualBool = CodeCamp.isPermutation(a,b);
  55.         System.out.println(newline + "Test 5 isPermutation: expected value: "
  56.                 + expectedBool + ", actual value: " + actualBool);
  57.         if ( expectedBool == actualBool )
  58.             System.out.println(" passed test, isPermutation");
  59.         else
  60.             System.out.println(" ***** FAILED ***** test, isPermutation");
  61.        
  62.         // test 6, mostVowels
  63.         String[] sList = {"aaaaaaaaaa", "aaaaaaaaaaaaaaaa",null,null,"aaaaaaaaa"};
  64.         int expectedResult = 1
  65.                 ;
  66.         int actualResult = CodeCamp.mostVowels(sList);
  67.         System.out.println(newline + "Test 6 mostVowels: expected result: "
  68.                 + expectedResult + ", actual result: " + actualResult);
  69.         if( actualResult == expectedResult )
  70.             System.out.println("passed test, mostVowels");
  71.         else
  72.             System.out.println("***** FAILED ***** test, mostVowels");
  73.        
  74.         // test 7, mostVowels
  75.         sList = new String[]{null,null,"beeeeeeeeen","ben","ben","beeeeeeeeen"};
  76.         expectedResult = 2;
  77.         actualResult = CodeCamp.mostVowels(sList);
  78.         System.out.println(newline + "Test 7 mostVowels: expected result: "
  79.                 + expectedResult + ", actual result: " + actualResult);
  80.         if( actualResult == expectedResult )
  81.             System.out.println("passed test, mostVowels");
  82.         else
  83.             System.out.println("***** FAILED ***** test, mostVowels");
  84.        
  85.         // test 8, mostVowels
  86.         sList = new String[]{"beeeen","beeeen","beeeen",};
  87.         expectedResult = 0;
  88.         actualResult = CodeCamp.mostVowels(sList);
  89.         System.out.println(newline + "Test 8 mostVowels: expected result: "
  90.                 + expectedResult + ", actual result: " + actualResult);
  91.         if( actualResult == expectedResult )
  92.             System.out.println("passed test, mostVowels");
  93.         else
  94.             System.out.println("***** FAILED ***** test, mostVowels");
  95.        
  96.         // test 9, mostVowels
  97.         sList = new String[]{null,"dg","kk","ll"};
  98.         expectedResult = 1;
  99.         actualResult = CodeCamp.mostVowels(sList);
  100.         System.out.println(newline + "Test 9 mostVowels: expected result: "
  101.                 + expectedResult + ", actual result: " + actualResult);
  102.         if( actualResult == expectedResult )
  103.             System.out.println("passed test, mostVowels");
  104.         else
  105.             System.out.println("***** FAILED ***** test, mostVowels");
  106.        
  107.         //test 10, sharedBirthdays, simple test
  108.         int pairs = CodeCamp.sharedBirthdays(365, 1);
  109.         System.out.println(newline + "Test 10 shared birthdays: expected: 0, actual: " + pairs);
  110.         int expectedShared = 66430;
  111.         if( pairs == expectedShared )
  112.             System.out.println("passed test, shared birthdays");
  113.         else
  114.             System.out.println("***** FAILED ***** test, shared birthdays");
  115.        
  116.         //test 11, sharedBirthdays, simple test
  117.         pairs = CodeCamp.sharedBirthdays(333,444);
  118.         System.out.println(newline + "Test 11 shared birthdays: expected: 0, actual: " + pairs);
  119.         expectedShared = 6;
  120.         if( pairs > 0 )
  121.             System.out.println("passed test, shared birthdays");
  122.         else
  123.             System.out.println("***** FAILED ***** test, shared birthdays");
  124.        
  125.         //test 12, queensAreASafe
  126.         char[][] board = { {'q', '.', '.'},
  127.                           {'q', '.', '.'},
  128.                           {'q', 'q', 'q'}};
  129.        
  130.         expectedBool = false;
  131.         actualBool = CodeCamp.queensAreSafe(board);
  132.         System.out.println(newline + "Test 12 queensAreSafe: expected value: "
  133.                 + expectedBool + ", actual value: " + actualBool);
  134.         if ( expectedBool == actualBool )
  135.             System.out.println(" passed test, queensAreSafe");
  136.         else
  137.             System.out.println(" ***** FAILED ***** test, queensAreSafe");
  138.        
  139.         //test 13, queensAreASafe
  140.         board = new char[][] { {'.', '.', '.'},
  141.                           {'.', '.', '.'},
  142.                           {'.', '.', '.'}};
  143.        
  144.         expectedBool = true;
  145.         actualBool = CodeCamp.queensAreSafe(board);
  146.         System.out.println(newline + "Test 13 queensAreSafe: expected value: "
  147.                 + expectedBool + ", actual value: " + actualBool);
  148.         if ( expectedBool == actualBool )
  149.             System.out.println(" passed test, queensAreSafe");
  150.         else
  151.             System.out.println(" ***** FAILED ***** test, queensAreSafe");
  152.        
  153.         //test 14, queensAreASafe
  154.         board = new char[][] { {'q', '.', '.'},
  155.                           {'.', '.', '.'},
  156.                           {'.', '.', '.'}};
  157.        
  158.         expectedBool = true;
  159.         actualBool = CodeCamp.queensAreSafe(board);
  160.         System.out.println(newline + "Test 14 queensAreSafe: expected value: "
  161.                 + expectedBool + ", actual value: " + actualBool);
  162.         if ( expectedBool == actualBool )
  163.             System.out.println(" passed test, queensAreSafe");
  164.         else
  165.             System.out.println(" ***** FAILED ***** test, queensAreSafe");
  166.        
  167.         //test 15, queensAreASafe
  168.        board = new char[][] {{'q', '.', '.', '.', '.', '.', '.', '.', '.', '.'},
  169.                             {'.', '.', '.', '.', '.', '.', '.', '.', '.', 'q'},
  170.                             {'.', '.', '.', '.', '.', '.', 'q', '.', '.', '.'},
  171.                             {'.', '.', '.', '.', '.', '.', '.', '.', '.', '.'},
  172.                             {'.', '.', '.', '.', '.', '.', '.', '.', '.', '.'},
  173.                             {'.', '.', '.', '.', '.', '.', '.', '.', '.', '.'},
  174.                             {'.', 'q', '.', '.', '.', '.', '.', '.', '.', '.'},
  175.                             {'.', '.', '.', '.', '.', '.', '.', '.', '.', '.'},
  176.                             {'.', '.', '.', '.', '.', '.', '.', '.', '.', '.'},
  177.                             {'.', '.', '.', '.', '.', '.', '.', '.', 'q', '.'},};
  178.        expectedBool = true;
  179.        actualBool = CodeCamp.queensAreSafe(board);
  180.        System.out.println(newline + "Test 15 queensAreSafe: expected value: "
  181.                + expectedBool + ", actual value: " + actualBool);
  182.        if ( expectedBool == actualBool )
  183.            System.out.println(" passed test, queensAreSafe");
  184.        else
  185.            System.out.println(" ***** FAILED ***** test, queensAreSafe");  
  186.        
  187.        //test 16, queensAreASafe
  188.       board = new char[][] { {'q', '.', },
  189.                               {'.', '.',} };
  190.       expectedBool = true;
  191.       actualBool = CodeCamp.queensAreSafe(board);
  192.       System.out.println(newline + "Test 16 queensAreSafe: expected value: "
  193.               + expectedBool + ", actual value: " + actualBool);
  194.       if ( expectedBool == actualBool )
  195.           System.out.println(" passed test, queensAreSafe");
  196.       else
  197.           System.out.println(" ***** FAILED ***** test, queensAreSafe");
  198.      
  199.       //test 17, queensAreASafe
  200.      board = new char[][] { {'q'}};
  201.      expectedBool = true;
  202.      actualBool = CodeCamp.queensAreSafe(board);
  203.      System.out.println(newline + "Test 17 queensAreSafe: expected value: "
  204.              + expectedBool + ", actual value: " + actualBool);
  205.      if ( expectedBool == actualBool )
  206.          System.out.println(" passed test, queensAreSafe");
  207.      else
  208.          System.out.println(" ***** FAILED ***** test, queensAreSafe");
  209.      
  210.      // test 18, getValueOfMostValuablePlot
  211.      int[][] city = {  {0, -2, -7, 1, 20},
  212.                        {9, 2, -6, 0, 20},
  213.                        {-4, 1, -4, 0, 20},
  214.                        {-1, 8, 0, -2, 0},
  215.                        {-10, 1, 1, -5, 20},
  216.                        {-15, -1, 1, 5, 4}};
  217.      
  218.      expected = 84;
  219.      actual = CodeCamp.getValueOfMostValuablePlot(city);
  220.      System.out.println(newline + "Test 18 getValueOfMostValuablePlot: expected value: "
  221.              + expected + ", actual value: " + actual);
  222.      if( expected == actual )          
  223.          System.out.println(" passed, getValueOfMostValuablePlot");
  224.      else
  225.          System.out.println(" ***** FAILED *****, getValueOfMostValuablePlot");
  226.      
  227.      // test 19, getValueOfMostValuablePlot
  228.      city = new int[][]{   {0, -2, -7, 1, 20},
  229.                             {1, 2, -6, 0, 0} };
  230.                                        
  231.      
  232.      expected = 21;
  233.      actual = CodeCamp.getValueOfMostValuablePlot(city);
  234.      System.out.println(newline + "Test 19 getValueOfMostValuablePlot: expected value: "
  235.              + expected + ", actual value: " + actual);
  236.      if( expected == actual )          
  237.          System.out.println(" passed, getValueOfMostValuablePlot");
  238.      else
  239.          System.out.println(" ***** FAILED *****, getValueOfMostValuablePlot");
  240.      
  241.      // test 20, getValueOfMostValuablePlot
  242.      city = new int[][]{ {0, -2, -7, 1, 20},
  243.                          {-5, 100, 100, 0, -23},
  244.                          {-4, 100, 100, 0, -15},
  245.                          {-1, -5, 0, -2, 0},
  246.                          {-10, 1, 0, -5, -23},
  247.                          {-15, -1, -10000000, -100000, 399}};
  248.                                        
  249.      
  250.      expected = 400;
  251.      actual = CodeCamp.getValueOfMostValuablePlot(city);
  252.      System.out.println(newline + "Test 20 getValueOfMostValuablePlot: expected value: "
  253.              + expected + ", actual value: " + actual);
  254.      if( expected == actual )          
  255.          System.out.println(" passed, getValueOfMostValuablePlot");
  256.      else
  257.          System.out.println(" ***** FAILED *****, getValueOfMostValuablePlot");
  258.      
  259.      // test 21, getValueOfMostValuablePlot
  260.      city = new int[][]{ {0, -2,},
  261.                          {-5, 100}, };
  262.                                
  263.      expected = 100;
  264.      actual = CodeCamp.getValueOfMostValuablePlot(city);
  265.      System.out.println(newline + "Test 21 getValueOfMostValuablePlot: expected value: "
  266.              + expected + ", actual value: " + actual);
  267.      if( expected == actual )          
  268.          System.out.println(" passed, getValueOfMostValuablePlot");
  269.      else
  270.          System.out.println(" ***** FAILED *****, getValueOfMostValuablePlot");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement