Advertisement
vmeansdev

MainTestExample

Sep 11th, 2019
421
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.72 KB | None | 0 0
  1. public class Main {
  2.  
  3.     public static void main(String[] args) {
  4.         testLinkedListCreatedEmpty();
  5.     }
  6.  
  7.     private static void testLinkedListCreatedEmpty() {
  8.         LinkedList list = new LinkedList();
  9.         test(list.count() == 0, "List should be empty");
  10.     }
  11.  
  12.     /*
  13.         TEST helper methods
  14.      */
  15.  
  16.     private static void test(boolean condition, String description) {
  17.         try {
  18.             check(condition, description);
  19.         } catch (Exception ex) {
  20.             ex.printStackTrace();
  21.         }
  22.     }
  23.  
  24.     private static void check(boolean condition, String description) throws Exception {
  25.         if (!condition) {
  26.             throw new Exception(description);
  27.         }
  28.     }
  29.  
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement