Deprecated: Creation of dynamic property wpdb::$categories is deprecated in /var/www/twodee/blog/wp-includes/wp-db.php on line 668

Deprecated: Creation of dynamic property wpdb::$post2cat is deprecated in /var/www/twodee/blog/wp-includes/wp-db.php on line 668

Deprecated: Creation of dynamic property wpdb::$link2cat is deprecated in /var/www/twodee/blog/wp-includes/wp-db.php on line 668

Deprecated: Return type of WP_Theme::offsetExists($offset) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/twodee/blog/wp-includes/class-wp-theme.php on line 554

Deprecated: Return type of WP_Theme::offsetGet($offset) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/twodee/blog/wp-includes/class-wp-theme.php on line 595

Deprecated: Return type of WP_Theme::offsetSet($offset, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/twodee/blog/wp-includes/class-wp-theme.php on line 535

Deprecated: Return type of WP_Theme::offsetUnset($offset) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/twodee/blog/wp-includes/class-wp-theme.php on line 544

Deprecated: Return type of WP_REST_Request::offsetExists($offset) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/twodee/blog/wp-includes/rest-api/class-wp-rest-request.php on line 960

Deprecated: Return type of WP_REST_Request::offsetGet($offset) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/twodee/blog/wp-includes/rest-api/class-wp-rest-request.php on line 980

Deprecated: Return type of WP_REST_Request::offsetSet($offset, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/twodee/blog/wp-includes/rest-api/class-wp-rest-request.php on line 992

Deprecated: Return type of WP_REST_Request::offsetUnset($offset) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/twodee/blog/wp-includes/rest-api/class-wp-rest-request.php on line 1003

Deprecated: Return type of WP_Block_List::current() should either be compatible with Iterator::current(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/twodee/blog/wp-includes/class-wp-block-list.php on line 151

Deprecated: Return type of WP_Block_List::next() should either be compatible with Iterator::next(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/twodee/blog/wp-includes/class-wp-block-list.php on line 175

Deprecated: Return type of WP_Block_List::key() should either be compatible with Iterator::key(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/twodee/blog/wp-includes/class-wp-block-list.php on line 164

Deprecated: Return type of WP_Block_List::valid() should either be compatible with Iterator::valid(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/twodee/blog/wp-includes/class-wp-block-list.php on line 186

Deprecated: Return type of WP_Block_List::rewind() should either be compatible with Iterator::rewind(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/twodee/blog/wp-includes/class-wp-block-list.php on line 138

Deprecated: Return type of WP_Block_List::offsetExists($index) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/twodee/blog/wp-includes/class-wp-block-list.php on line 75

Deprecated: Return type of WP_Block_List::offsetGet($index) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/twodee/blog/wp-includes/class-wp-block-list.php on line 89

Deprecated: Return type of WP_Block_List::offsetSet($index, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/twodee/blog/wp-includes/class-wp-block-list.php on line 110

Deprecated: Return type of WP_Block_List::offsetUnset($index) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/twodee/blog/wp-includes/class-wp-block-list.php on line 127

Deprecated: Return type of WP_Block_List::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/twodee/blog/wp-includes/class-wp-block-list.php on line 199

Deprecated: Creation of dynamic property Automattic\Jetpack\Connection\Manager::$error_handler is deprecated in /var/www/twodee/blog/wp-content/plugins/jetpack/vendor/automattic/jetpack-connection/src/class-manager.php on line 91

Deprecated: Creation of dynamic property WPCOM_REST_API_V2_Endpoint_Instagram_Gallery::$is_wpcom is deprecated in /var/www/twodee/blog/wp-content/plugins/jetpack/_inc/lib/core-api/wpcom-endpoints/class-wpcom-rest-api-v2-endpoint-instagram-gallery.php on line 23

Deprecated: Creation of dynamic property WPCOM_REST_API_V2_Endpoint_Mailchimp::$wpcom_is_wpcom_only_endpoint is deprecated in /var/www/twodee/blog/wp-content/plugins/jetpack/_inc/lib/core-api/wpcom-endpoints/class-wpcom-rest-api-v2-endpoint-mailchimp.php on line 17

Deprecated: Creation of dynamic property WPCOM_REST_API_V2_Endpoint_Tweetstorm_Gather::$wpcom_is_wpcom_only_endpoint is deprecated in /var/www/twodee/blog/wp-content/plugins/jetpack/_inc/lib/core-api/wpcom-endpoints/class-wpcom-rest-api-v2-endpoint-tweetstorm-gather.php on line 21

Deprecated: Creation of dynamic property WPCOM_REST_API_V2_Endpoint_Tweetstorm_Gather::$is_wpcom is deprecated in /var/www/twodee/blog/wp-content/plugins/jetpack/_inc/lib/core-api/wpcom-endpoints/class-wpcom-rest-api-v2-endpoint-tweetstorm-gather.php on line 22

Deprecated: Creation of dynamic property WPCOM_REST_API_V2_Endpoint_Gutenberg_Available_Extensions::$wpcom_is_site_specific_endpoint is deprecated in /var/www/twodee/blog/wp-content/plugins/jetpack/_inc/lib/core-api/wpcom-endpoints/gutenberg-available-extensions.php on line 20

Deprecated: Creation of dynamic property WPCOM_REST_API_V2_Endpoint_Memberships::$wpcom_is_wpcom_only_endpoint is deprecated in /var/www/twodee/blog/wp-content/plugins/jetpack/_inc/lib/core-api/wpcom-endpoints/memberships.php on line 23

Deprecated: Creation of dynamic property WPCOM_REST_API_V2_Endpoint_Memberships::$wpcom_is_site_specific_endpoint is deprecated in /var/www/twodee/blog/wp-content/plugins/jetpack/_inc/lib/core-api/wpcom-endpoints/memberships.php on line 24

Deprecated: Creation of dynamic property WPCOM_REST_API_V2_Endpoint_Subscribers::$wpcom_is_wpcom_only_endpoint is deprecated in /var/www/twodee/blog/wp-content/plugins/jetpack/_inc/lib/core-api/wpcom-endpoints/subscribers.php on line 15

Deprecated: Creation of dynamic property Automattic\Jetpack\Sync\Queue::$random_int is deprecated in /var/www/twodee/blog/wp-content/plugins/jetpack/vendor/automattic/jetpack-sync/src/class-queue.php on line 38

Deprecated: Creation of dynamic property Automattic\Jetpack\Sync\Queue::$random_int is deprecated in /var/www/twodee/blog/wp-content/plugins/jetpack/vendor/automattic/jetpack-sync/src/class-queue.php on line 38

Deprecated: Creation of dynamic property WPCOM_Widget_Goodreads::$shelves is deprecated in /var/www/twodee/blog/wp-content/plugins/jetpack/modules/widgets/goodreads.php on line 33

Deprecated: DateTime::__construct(): Passing null to parameter #1 ($datetime) of type string is deprecated in /var/www/twodee/blog/wp-includes/script-loader.php on line 348

Deprecated: Creation of dynamic property Advanced_Editor_Tools::$toolbar_classic_block is deprecated in /var/www/twodee/blog/wp-content/plugins/tinymce-advanced/tinymce-advanced.php on line 347

Deprecated: Creation of dynamic property Advanced_Editor_Tools::$toolbar_block is deprecated in /var/www/twodee/blog/wp-content/plugins/tinymce-advanced/tinymce-advanced.php on line 349

Deprecated: Creation of dynamic property Advanced_Editor_Tools::$toolbar_block_side is deprecated in /var/www/twodee/blog/wp-content/plugins/tinymce-advanced/tinymce-advanced.php on line 350

Deprecated: Creation of dynamic property Advanced_Editor_Tools::$panels_block is deprecated in /var/www/twodee/blog/wp-content/plugins/tinymce-advanced/tinymce-advanced.php on line 351

Deprecated: Creation of dynamic property Advanced_Editor_Tools::$used_block_buttons is deprecated in /var/www/twodee/blog/wp-content/plugins/tinymce-advanced/tinymce-advanced.php on line 354

Deprecated: Creation of dynamic property WP_Block_Type::$plan_check is deprecated in /var/www/twodee/blog/wp-includes/class-wp-block-type.php on line 333

Deprecated: Creation of dynamic property WP_Block_Type::$plan_check is deprecated in /var/www/twodee/blog/wp-includes/class-wp-block-type.php on line 333

Deprecated: Creation of dynamic property WP_Block_Type::$plan_check is deprecated in /var/www/twodee/blog/wp-includes/class-wp-block-type.php on line 333

Deprecated: Creation of dynamic property WP_Block_Type::$plan_check is deprecated in /var/www/twodee/blog/wp-includes/class-wp-block-type.php on line 333

Deprecated: Creation of dynamic property WP_Block_Type::$plan_check is deprecated in /var/www/twodee/blog/wp-includes/class-wp-block-type.php on line 333

Deprecated: Creation of dynamic property WP_Block_Type::$plan_check is deprecated in /var/www/twodee/blog/wp-includes/class-wp-block-type.php on line 333

Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /var/www/twodee/blog/wp-includes/class-wp-term.php on line 198

Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /var/www/twodee/blog/wp-includes/class-wp-term.php on line 198

Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /var/www/twodee/blog/wp-includes/class-wp-term.php on line 198

Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /var/www/twodee/blog/wp-includes/class-wp-term.php on line 198

Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /var/www/twodee/blog/wp-includes/class-wp-term.php on line 198
» CS 1: Lecture 36 – Unit Testing

teaching machines

CS 1: Lecture 36 – Unit Testing

December 8, 2017 by . Filed under
Deprecated: Creation of dynamic property WP_Term::$cat_ID is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 378

Deprecated: Creation of dynamic property WP_Term::$category_count is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 379

Deprecated: Creation of dynamic property WP_Term::$category_description is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 380

Deprecated: Creation of dynamic property WP_Term::$cat_name is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 381

Deprecated: Creation of dynamic property WP_Term::$category_nicename is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 382

Deprecated: Creation of dynamic property WP_Term::$category_parent is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 383

Deprecated: Creation of dynamic property WP_Term::$cat_ID is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 378

Deprecated: Creation of dynamic property WP_Term::$category_count is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 379

Deprecated: Creation of dynamic property WP_Term::$category_description is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 380

Deprecated: Creation of dynamic property WP_Term::$cat_name is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 381

Deprecated: Creation of dynamic property WP_Term::$category_nicename is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 382

Deprecated: Creation of dynamic property WP_Term::$category_parent is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 383

Deprecated: Creation of dynamic property WP_Term::$cat_ID is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 378

Deprecated: Creation of dynamic property WP_Term::$category_count is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 379

Deprecated: Creation of dynamic property WP_Term::$category_description is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 380

Deprecated: Creation of dynamic property WP_Term::$cat_name is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 381

Deprecated: Creation of dynamic property WP_Term::$category_nicename is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 382

Deprecated: Creation of dynamic property WP_Term::$category_parent is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 383

Deprecated: Creation of dynamic property WP_Term::$cat_ID is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 378

Deprecated: Creation of dynamic property WP_Term::$category_count is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 379

Deprecated: Creation of dynamic property WP_Term::$category_description is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 380

Deprecated: Creation of dynamic property WP_Term::$cat_name is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 381

Deprecated: Creation of dynamic property WP_Term::$category_nicename is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 382

Deprecated: Creation of dynamic property WP_Term::$category_parent is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 383

Deprecated: Creation of dynamic property WP_Term::$cat_ID is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 378

Deprecated: Creation of dynamic property WP_Term::$category_count is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 379

Deprecated: Creation of dynamic property WP_Term::$category_description is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 380

Deprecated: Creation of dynamic property WP_Term::$cat_name is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 381

Deprecated: Creation of dynamic property WP_Term::$category_nicename is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 382

Deprecated: Creation of dynamic property WP_Term::$category_parent is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 383
cs1, cs145, cs148, fall 2017, lectures.

Dear students,

Today, we examine one of the less glamorous aspects of writing code: testing it. There are three big reasons to write systematic tests of your software:

  1. To make sure that your code does what you think it does.
  2. To expand your thinking into situations outside your normal parameter ranges and workflow.
  3. To ensure that changes made later in development do not break code written earlier. When you add feature Z, you probably aren’t thinking much about feature A, so it’s nice to have a bunch of tests around that determine if feature A still works properly.

There’s are psychological reasons too. It’s way better to discover your own errors than to have someone else tell you your code’s broken. See SpecCheckers.

To demonstrate what it means to test our code, we will use the popular JUnit testing framework for Java. We write a method for each feature under test. These methods have the following form:

@Test
public void testFeatureA() {
  Foo f = new Foo();
  int expectedValue = ...;
  int actualValue = f.featureA();
  Assert.assertEquals("Foo.featureA didn't do what I expected it to do when...",
                      expectedValue,
                      actualValue);
}

When we run this code as a JUnit test suite in a modern development environment, we get a nice report of which features are passing and which are failing.

So, let’s write some unit tests against your ArrayList implementations from last class!

If you are curious how the folks behind the OpenJDK project chose to implement ArrayList, see their open source solution.

Here’s your TODO to complete before we meet again:

See you next class!

Sincerely,

P.S. Here’s the code we wrote together…

StringList.java

package lecture1208;

public class StringList {
  int N;
  String[] a;

  public StringList() {
    N = 0;
    a = new String[2];
  }

  public void add(String element) {
    if (N >= a.length) {
      String[] b = new String[a.length * 2];
      for (int i = 0; i < a.length; i++) {
        b[i] = a[i];
      }
      a = b;
    }
    a[N] = element;
    N++;

  }

  public void remove(int index) {
    String[] dst = new String[a.length - 1];
    for (int i = 0; i < a.length; i++) {
      if (i < index) {
        dst[i] = a[i];
      }
      if (i > index) {
        dst[i - 1] = a[i];
      }
    }
    a = dst;
    N--;
  }

  public int size() {
    return N;
  }

  public boolean contains(String str) {
    for (int i = 0; i < N; ++i) {
      if (a[i].equals(str)) {
        return true;
      }
    }
    return false;
  }

  public String get(int index) {
    return a[index];
  }

  public boolean isEmpty() {
    return N == 0;
  }

  public int indexOf(String needle) {
//    int counter = 0;
//    while (!a[counter].equals(needle)) {
//      counter++;
//    }
//    return counter;
    
    for (int i = 0; i < N; ++i) {
      if (a[i].equals(needle)) {
        return i;
      }
    }
    return -1;
  }
}

Tests.java

package lecture1208;

import org.junit.Assert;
import org.junit.Test;

public class Tests {
  @Test
  public void testEmpty() {
    StringList list = new StringList();
    Assert.assertEquals("I tried calling size on an empty list, but :(", 0, list.size());
    Assert.assertEquals("I tried asking an empty list if it contained hope, but :(", false, list.contains("hope"));
    Assert.assertEquals("I tried asking an empty list if it was empty, but :(", true, list.isEmpty());
    Assert.assertEquals("I tried getting indexOf(hope) on an empty list, but :(", -1, list.indexOf("hope"));

  }
  
  @Test
  public void testOnesie() {
    StringList list = new StringList();
    list.add("hope");
    Assert.assertEquals("I tried calling size on a 1-list, but :(", 1, list.size());
    Assert.assertEquals("I tried asking a 1-list if it contained hope, but :(", true, list.contains("hope"));
    Assert.assertEquals("I tried asking a 1-list if it was empty, but :(", false, list.isEmpty());
    Assert.assertEquals("I tried getting element 0 from a 1-list, but :(", "hope", list.get(0));
    Assert.assertEquals("I tried getting indexOf(hope) on a 1-list, but :(", 0, list.indexOf("hope"));
  }
  
  @Test
  public void testRemoveFromOnesie() {
    StringList list = new StringList();
    list.add("hope");
    list.remove(0);
    Assert.assertEquals("I tried calling size on an empty list, but :(", 0, list.size());
    Assert.assertEquals("I tried asking an empty list if it contained hope, but :(", false, list.contains("hope"));
    Assert.assertEquals("I tried asking an empty list if it was empty, but :(", true, list.isEmpty());
  }
  
  @Test
  public void testLotsies() {
    StringList list = new StringList();
    list.add("hope");
    list.add("element");
    list.add("failure");
    list.add("success");
    Assert.assertEquals("I tried calling size on a 4-list, but :(", 4, list.size());
    Assert.assertEquals("I tried asking a 4-list if it contained hope, but :(", true, list.contains("hope"));
    Assert.assertEquals("I tried asking a 4-list if it contained hope, but :(", true, list.contains("element"));
    Assert.assertEquals("I tried asking a 4-list if it contained hope, but :(", true, list.contains("failure"));
    Assert.assertEquals("I tried asking a 4-list if it contained hope, but :(", true, list.contains("success"));
    Assert.assertEquals("I tried asking a 4-list if it was empty, but :(", false, list.isEmpty());
    Assert.assertEquals("I tried getting element 0 from a 1-list, but :(", "hope", list.get(0));
    Assert.assertEquals("I tried getting element 1 from a 1-list, but :(", "element", list.get(1));
    Assert.assertEquals("I tried getting element 2 from a 1-list, but :(", "failure", list.get(2));
    Assert.assertEquals("I tried getting element 3 from a 1-list, but :(", "success", list.get(3));
    Assert.assertEquals("I tried getting indexOf(hope) on a 1-list, but :(", 0, list.indexOf("hope"));
    Assert.assertEquals("I tried getting indexOf(element) on a 1-list, but :(", 1, list.indexOf("element"));
    Assert.assertEquals("I tried getting indexOf(failure) on a 1-list, but :(", 2, list.indexOf("failure"));
    Assert.assertEquals("I tried getting indexOf(success) on a 1-list, but :(", 3, list.indexOf("success"));

  }
}

GrowableArray.java

package lecture1208;

public class GrowableArray {
  private String[] currentStringArray;
  private int nelements;

  public GrowableArray() {
    currentStringArray = new String[10];
    nelements = 0;
  }

  public String get(int i) {
    return currentStringArray[i];
  }

  public boolean isEmpty() {
    return nelements == 0;
  }

  public void remove(int index) {
    String[] newArray = new String[currentStringArray.length - 1];
    for (int i = 0; i < index; i++) {
      newArray[i] = currentStringArray[i];
    }
    for (int i = index; i < newArray.length; i++) {
      newArray[i] = currentStringArray[i + 1];
    }
    currentStringArray = newArray;
    --nelements;
  }

  public boolean contains(String string) {
    boolean isTrue = false;
    for (int i = 0; i < nelements; i++) {
      if (currentStringArray[i].equals(string)) {
        isTrue = true;
      }
    }
    return isTrue;
  }

  public int indexOf(String s) {
    for (int i = 0; i < nelements; i++) {
      if (currentStringArray[i].equals(s)) {
        return i;
      }
    }
    return -1;
  }

  public int size() {
    return nelements;
  }

  public void add(String s) {
    if (nelements == currentStringArray.length) {
      String[] moar = new String[2 * nelements];
      System.arraycopy(currentStringArray, 0, moar, 0, nelements);
      currentStringArray = moar;
    }
    currentStringArray[nelements] = s;
    ++nelements;
  }
}

Tests.java

package lecture1208;

import org.junit.Assert;
import org.junit.Test;

public class Tests {
  @Test
  public void testEmpty() {
    GrowableArray list = new GrowableArray();
    Assert.assertEquals("I tried asking an empty list if it was empty, but...", true, list.isEmpty());
    Assert.assertEquals("I tried asking an empty list its size, but...", 0, list.size());
    Assert.assertEquals("I tried asking an empty list if it had hope, but...", false, list.contains("hope"));
  }
  
  @Test
  public void testOnesie() {
    GrowableArray list = new GrowableArray();
    list.add("hope");
    Assert.assertEquals("I tried asking a 1 list if it was empty, but...", false, list.isEmpty());
    Assert.assertEquals("I tried asking a 1 list its size, but...", 1, list.size());
    Assert.assertEquals("I tried asking a 1 list if it had hope, but...", true, list.contains("hope"));
    Assert.assertEquals("I tried asking a 1 list about indexOf hope, but...", 0, list.indexOf("hope"));
    list.remove(0);
    Assert.assertEquals("I tried asking an empty list if it was empty, but...", true, list.isEmpty());
    Assert.assertEquals("I tried asking an empty list its size, but...", 0, list.size());
    Assert.assertEquals("I tried asking an empty list if it had hope, but...", false, list.contains("hope"));
  }
  
  @Test
  public void testLotsies() {
    GrowableArray list = new GrowableArray();
    list.add("hope");
    list.add("peace");
    list.add("joy");
    list.add("love");
    Assert.assertEquals("I tried asking a 4 list if it was empty, but...", false, list.isEmpty());
    Assert.assertEquals("I tried asking a 4 list its size, but...", 4, list.size());
    Assert.assertEquals("I tried asking a 4 list if it had hope, but...", true, list.contains("hope"));
    Assert.assertEquals("I tried asking a 4 list if it had peace, but...", true, list.contains("peace"));
    Assert.assertEquals("I tried asking a 4 list if it had joy, but...", true, list.contains("joy"));
    Assert.assertEquals("I tried asking a 4 list if it had love, but...", true, list.contains("love"));
    Assert.assertEquals("I tried asking a 4 list if it had love , but...", false, list.contains("love "));

    Assert.assertEquals("I tried asking a 4 list about indexOf hope, but...", 0, list.indexOf("hope"));
    Assert.assertEquals("I tried asking a 4 list about indexOf peace, but...", 1, list.indexOf("peace"));
    Assert.assertEquals("I tried asking a 4 list about indexOf joy, but...", 2, list.indexOf("joy"));
    Assert.assertEquals("I tried asking a 4 list about indexOf love, but...", 3, list.indexOf("love"));
    Assert.assertEquals("I tried asking a 4 list about indexOf love , but...", -1, list.indexOf("love "));

//    list.remove(0);
//    Assert.assertEquals("I tried asking an empty list if it was empty, but...", true, list.isEmpty());
//    Assert.assertEquals("I tried asking an empty list its size, but...", 0, list.size());
//    Assert.assertEquals("I tried asking an empty list if it had hope, but...", false, list.contains("hope"));
  }
}