Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //test 1, hammingDistance
- int[] list1 = {1, 2, 3, 4, 5, 6, 7, 8, 9};
- int[] list2 = {1, 2, 3, 4, 5, 6, 7, 8, 9};
- int expected = 0;
- int actual = CodeCamp.hammingDistance(list1,list2);
- System.out.println("Test 1 hamming distance: expected value: " +
- expected + ", actual value: " + actual);
- if( expected == actual )
- System.out.println(" passed test, hamming distance");
- else
- System.out.println(" ***** FAILED ***** test, hamming distance");
- System.out.println();
- //test 2, hammingDistance
- list1 = new int[] {1, 2, 3, 4, 5, 6, 7, 8};
- list2 = new int[] {2, 3, 4, 5, 5, 6, 9, 8};
- expected = 5;
- actual = CodeCamp.hammingDistance(list1,list2);
- System.out.println("Test 2 hamming distance: expected value: " +
- expected + ", actual value: " + actual);
- if( expected == actual )
- System.out.println(" passed test, hamming distance");
- else
- System.out.println(" ***** FAILED ***** test, hamming distance");
- //test 3, isPermutation
- int[] a = {5, 5};
- int[] b = {2, 1, 3};
- boolean expectedBool = false;
- boolean actualBool = CodeCamp.isPermutation(a,b);
- System.out.println(newline + "Test 3 isPermutation: expected value: "
- + expectedBool + ", actual value: " + actualBool);
- if ( expectedBool == actualBool )
- System.out.println(" passed test, isPermutation");
- else
- System.out.println(" ***** FAILED ***** test, isPermutation");
- //test 4, isPermutation
- a = new int[]{1,1,1,1,1};
- b = new int[]{1,1,1,1,1};
- expectedBool = true;
- actualBool = CodeCamp.isPermutation(a,b);
- System.out.println(newline + "Test 4 isPermutation: expected value: "
- + expectedBool + ", actual value: " + actualBool);
- if ( expectedBool == actualBool )
- System.out.println(" passed test, isPermutation");
- else
- System.out.println(" ***** FAILED ***** test, isPermutation");
- //test 5, isPermutation
- a = new int[]{10,30000000,500000,129219129,12111,3536};
- b = new int[]{30000000,500000,12111,3536,10,129219129};
- expectedBool = true;
- actualBool = CodeCamp.isPermutation(a,b);
- System.out.println(newline + "Test 5 isPermutation: expected value: "
- + expectedBool + ", actual value: " + actualBool);
- if ( expectedBool == actualBool )
- System.out.println(" passed test, isPermutation");
- else
- System.out.println(" ***** FAILED ***** test, isPermutation");
- // test 6, mostVowels
- String[] sList = {"aaaaaaaaaa", "aaaaaaaaaaaaaaaa",null,null,"aaaaaaaaa"};
- int expectedResult = 1
- ;
- int actualResult = CodeCamp.mostVowels(sList);
- System.out.println(newline + "Test 6 mostVowels: expected result: "
- + expectedResult + ", actual result: " + actualResult);
- if( actualResult == expectedResult )
- System.out.println("passed test, mostVowels");
- else
- System.out.println("***** FAILED ***** test, mostVowels");
- // test 7, mostVowels
- sList = new String[]{null,null,"beeeeeeeeen","ben","ben","beeeeeeeeen"};
- expectedResult = 2;
- actualResult = CodeCamp.mostVowels(sList);
- System.out.println(newline + "Test 7 mostVowels: expected result: "
- + expectedResult + ", actual result: " + actualResult);
- if( actualResult == expectedResult )
- System.out.println("passed test, mostVowels");
- else
- System.out.println("***** FAILED ***** test, mostVowels");
- // test 8, mostVowels
- sList = new String[]{"beeeen","beeeen","beeeen",};
- expectedResult = 0;
- actualResult = CodeCamp.mostVowels(sList);
- System.out.println(newline + "Test 8 mostVowels: expected result: "
- + expectedResult + ", actual result: " + actualResult);
- if( actualResult == expectedResult )
- System.out.println("passed test, mostVowels");
- else
- System.out.println("***** FAILED ***** test, mostVowels");
- // test 9, mostVowels
- sList = new String[]{null,"dg","kk","ll"};
- expectedResult = 1;
- actualResult = CodeCamp.mostVowels(sList);
- System.out.println(newline + "Test 9 mostVowels: expected result: "
- + expectedResult + ", actual result: " + actualResult);
- if( actualResult == expectedResult )
- System.out.println("passed test, mostVowels");
- else
- System.out.println("***** FAILED ***** test, mostVowels");
- //test 10, sharedBirthdays, simple test
- int pairs = CodeCamp.sharedBirthdays(365, 1);
- System.out.println(newline + "Test 10 shared birthdays: expected: 0, actual: " + pairs);
- int expectedShared = 66430;
- if( pairs == expectedShared )
- System.out.println("passed test, shared birthdays");
- else
- System.out.println("***** FAILED ***** test, shared birthdays");
- //test 11, sharedBirthdays, simple test
- pairs = CodeCamp.sharedBirthdays(333,444);
- System.out.println(newline + "Test 11 shared birthdays: expected: 0, actual: " + pairs);
- expectedShared = 6;
- if( pairs > 0 )
- System.out.println("passed test, shared birthdays");
- else
- System.out.println("***** FAILED ***** test, shared birthdays");
- //test 12, queensAreASafe
- char[][] board = { {'q', '.', '.'},
- {'q', '.', '.'},
- {'q', 'q', 'q'}};
- expectedBool = false;
- actualBool = CodeCamp.queensAreSafe(board);
- System.out.println(newline + "Test 12 queensAreSafe: expected value: "
- + expectedBool + ", actual value: " + actualBool);
- if ( expectedBool == actualBool )
- System.out.println(" passed test, queensAreSafe");
- else
- System.out.println(" ***** FAILED ***** test, queensAreSafe");
- //test 13, queensAreASafe
- board = new char[][] { {'.', '.', '.'},
- {'.', '.', '.'},
- {'.', '.', '.'}};
- expectedBool = true;
- actualBool = CodeCamp.queensAreSafe(board);
- System.out.println(newline + "Test 13 queensAreSafe: expected value: "
- + expectedBool + ", actual value: " + actualBool);
- if ( expectedBool == actualBool )
- System.out.println(" passed test, queensAreSafe");
- else
- System.out.println(" ***** FAILED ***** test, queensAreSafe");
- //test 14, queensAreASafe
- board = new char[][] { {'q', '.', '.'},
- {'.', '.', '.'},
- {'.', '.', '.'}};
- expectedBool = true;
- actualBool = CodeCamp.queensAreSafe(board);
- System.out.println(newline + "Test 14 queensAreSafe: expected value: "
- + expectedBool + ", actual value: " + actualBool);
- if ( expectedBool == actualBool )
- System.out.println(" passed test, queensAreSafe");
- else
- System.out.println(" ***** FAILED ***** test, queensAreSafe");
- //test 15, queensAreASafe
- board = new char[][] {{'q', '.', '.', '.', '.', '.', '.', '.', '.', '.'},
- {'.', '.', '.', '.', '.', '.', '.', '.', '.', 'q'},
- {'.', '.', '.', '.', '.', '.', 'q', '.', '.', '.'},
- {'.', '.', '.', '.', '.', '.', '.', '.', '.', '.'},
- {'.', '.', '.', '.', '.', '.', '.', '.', '.', '.'},
- {'.', '.', '.', '.', '.', '.', '.', '.', '.', '.'},
- {'.', 'q', '.', '.', '.', '.', '.', '.', '.', '.'},
- {'.', '.', '.', '.', '.', '.', '.', '.', '.', '.'},
- {'.', '.', '.', '.', '.', '.', '.', '.', '.', '.'},
- {'.', '.', '.', '.', '.', '.', '.', '.', 'q', '.'},};
- expectedBool = true;
- actualBool = CodeCamp.queensAreSafe(board);
- System.out.println(newline + "Test 15 queensAreSafe: expected value: "
- + expectedBool + ", actual value: " + actualBool);
- if ( expectedBool == actualBool )
- System.out.println(" passed test, queensAreSafe");
- else
- System.out.println(" ***** FAILED ***** test, queensAreSafe");
- //test 16, queensAreASafe
- board = new char[][] { {'q', '.', },
- {'.', '.',} };
- expectedBool = true;
- actualBool = CodeCamp.queensAreSafe(board);
- System.out.println(newline + "Test 16 queensAreSafe: expected value: "
- + expectedBool + ", actual value: " + actualBool);
- if ( expectedBool == actualBool )
- System.out.println(" passed test, queensAreSafe");
- else
- System.out.println(" ***** FAILED ***** test, queensAreSafe");
- //test 17, queensAreASafe
- board = new char[][] { {'q'}};
- expectedBool = true;
- actualBool = CodeCamp.queensAreSafe(board);
- System.out.println(newline + "Test 17 queensAreSafe: expected value: "
- + expectedBool + ", actual value: " + actualBool);
- if ( expectedBool == actualBool )
- System.out.println(" passed test, queensAreSafe");
- else
- System.out.println(" ***** FAILED ***** test, queensAreSafe");
- // test 18, getValueOfMostValuablePlot
- int[][] city = { {0, -2, -7, 1, 20},
- {9, 2, -6, 0, 20},
- {-4, 1, -4, 0, 20},
- {-1, 8, 0, -2, 0},
- {-10, 1, 1, -5, 20},
- {-15, -1, 1, 5, 4}};
- expected = 84;
- actual = CodeCamp.getValueOfMostValuablePlot(city);
- System.out.println(newline + "Test 18 getValueOfMostValuablePlot: expected value: "
- + expected + ", actual value: " + actual);
- if( expected == actual )
- System.out.println(" passed, getValueOfMostValuablePlot");
- else
- System.out.println(" ***** FAILED *****, getValueOfMostValuablePlot");
- // test 19, getValueOfMostValuablePlot
- city = new int[][]{ {0, -2, -7, 1, 20},
- {1, 2, -6, 0, 0} };
- expected = 21;
- actual = CodeCamp.getValueOfMostValuablePlot(city);
- System.out.println(newline + "Test 19 getValueOfMostValuablePlot: expected value: "
- + expected + ", actual value: " + actual);
- if( expected == actual )
- System.out.println(" passed, getValueOfMostValuablePlot");
- else
- System.out.println(" ***** FAILED *****, getValueOfMostValuablePlot");
- // test 20, getValueOfMostValuablePlot
- city = new int[][]{ {0, -2, -7, 1, 20},
- {-5, 100, 100, 0, -23},
- {-4, 100, 100, 0, -15},
- {-1, -5, 0, -2, 0},
- {-10, 1, 0, -5, -23},
- {-15, -1, -10000000, -100000, 399}};
- expected = 400;
- actual = CodeCamp.getValueOfMostValuablePlot(city);
- System.out.println(newline + "Test 20 getValueOfMostValuablePlot: expected value: "
- + expected + ", actual value: " + actual);
- if( expected == actual )
- System.out.println(" passed, getValueOfMostValuablePlot");
- else
- System.out.println(" ***** FAILED *****, getValueOfMostValuablePlot");
- // test 21, getValueOfMostValuablePlot
- city = new int[][]{ {0, -2,},
- {-5, 100}, };
- expected = 100;
- actual = CodeCamp.getValueOfMostValuablePlot(city);
- System.out.println(newline + "Test 21 getValueOfMostValuablePlot: expected value: "
- + expected + ", actual value: " + actual);
- if( expected == actual )
- System.out.println(" passed, getValueOfMostValuablePlot");
- else
- System.out.println(" ***** FAILED *****, getValueOfMostValuablePlot");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement