package com.google.openlocationcode.tests;

import com.google.openlocationcode.OpenLocationCode;

import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

/**
 * Tests methods {@link com.google.openlocationcode.OpenLocationCode#isValidCode(String)},
 * {@link com.google.openlocationcode.OpenLocationCode#isShortCode(String)}} and
 * {@link com.google.openlocationcode.OpenLocationCode#isFullCode(String)} Open Location Code.
 */
@RunWith(JUnit4.class)
public class ValidityTest {

  private class TestData {

    private final String code;
    private final boolean isValid;
    private final boolean isShort;
    private final boolean isFull;

    public TestData(String line) {
      String[] parts = line.split(",");
      if (parts.length != 4) {
        throw new IllegalArgumentException("Wrong format of testing data.");
      }
      this.code = parts[0];
      this.isValid = Boolean.valueOf(parts[1]);
      this.isShort = Boolean.valueOf(parts[2]);
      this.isFull = Boolean.valueOf(parts[3]);
    }
  }

  private final List<TestData> testDataList = new ArrayList<>();

  @Before
  public void setUp() throws Exception {
    File testFile = new File(System.getenv("JAVA_RUNFILES"), "openlocationcode/test_data/validityTests.csv");
    InputStream testDataStream = new FileInputStream(testFile);
    BufferedReader reader = new BufferedReader(new InputStreamReader(testDataStream));
    String line;
    while ((line = reader.readLine()) != null) {
      if (line.startsWith("#")) {
        continue;
      }
      testDataList.add(new TestData(line));
    }
  }

  @Test
  public void testIsValid() {
    for (TestData testData : testDataList) {
      Assert.assertEquals(
          "Validity of code " + testData.code + " is wrong.",
          testData.isValid,
          OpenLocationCode.isValidCode(testData.code));
    }
  }

  @Test
  public void testIsShort() {
    for (TestData testData : testDataList) {
      Assert.assertEquals(
          "Shortness of code " + testData.code + " is wrong.",
          testData.isShort,
          OpenLocationCode.isShortCode(testData.code));
    }
  }

  @Test
  public void testIsFull() {
    for (TestData testData : testDataList) {
      Assert.assertEquals(
          "Fullness of code " + testData.code + " is wrong.",
          testData.isFull,
          OpenLocationCode.isFullCode(testData.code));
    }
  }
}

@@ -1293,16 +1293,128 @@
  %7D%0A  %7D%0A%0A
+  private static final String TEST_PATH =%0A      System.getenv(%22JAVA_RUNFILES%22) + %22/openlocationcode/test_data%22;%0A
   privat
@@ -1555,68 +1555,20 @@
 ile(
-System.getenv(%22JAVA_RUNFILES%22), %22openlocationcode/test_data/
+TEST_PATH, %22
 vali

Update ValidityTest.java