コード例 #1
0
  @Test
  /* Structural Basis, Nominal Case */
  public void testCompressInput() throws IOException {
    // The given file will go through both parts of the if-statement.
    Segmentator seg = new Segmentator(3, "test.txt");
    Segmentator.Test test = seg.new Test();

    List<String> segmentsToCompress = seg.segmentString();

    List<Integer> actualList = test.testCompressInput(segmentsToCompress);
    List<Integer> expectedList = new ArrayList<Integer>();
    expectedList.add(0);
    expectedList.add(1);
    expectedList.add(2);
    expectedList.add(3);
    expectedList.add(4);
    expectedList.add(3);
    expectedList.add(4);
    expectedList.add(1);
    expectedList.add(5);
    expectedList.add(3);
    expectedList.add(2);
    expectedList.add(3);
    expectedList.add(1);
    expectedList.add(6);
    expectedList.add(7);
    expectedList.add(8);

    assertEquals(expectedList, actualList);
  }
コード例 #2
0
  @Test
  /* Structural Basis */
  public void testAddBufferEmptyString() {
    Segmentator seg = new Segmentator(1, "test.txt");
    Segmentator.Test test = seg.new Test();

    assertTrue(test.testAddBuffer(""));
  }
コード例 #3
0
  @Test
  /* Structural Basis */
  public void testResetCompressionVars() {
    Segmentator seg = new Segmentator(1, "test.txt");
    Segmentator.Test test = seg.new Test();

    assertTrue(test.testResetCompressionVars());
  }
コード例 #4
0
  @Test
  /* Structural Basis */
  public void testPunctuationChar() {
    Segmentator seg = new Segmentator(1, "test.txt");
    Segmentator.Test test = seg.new Test();

    assertEquals(true, test.testIsPunctuation('.'));
  }
コード例 #5
0
  @Test
  /* Structural Basis, Data Flow */
  public void testCompressInputAllSameSeg() throws IOException {
    // The file will have all the same segment and will go into the else once and then the if
    // exclusively
    Segmentator seg = new Segmentator(3, "SameSegments.txt");
    Segmentator.Test test = seg.new Test();

    List<String> segmentsToCompress = seg.segmentString();

    List<Integer> actualList = test.testCompressInput(segmentsToCompress);
    List<Integer> expectedList = new ArrayList<Integer>();
    expectedList.add(0);
    expectedList.add(0);
    expectedList.add(0);

    assertEquals(expectedList, actualList);
  }
コード例 #6
0
  @Test
  /* Structural Basis, Data Flow */
  public void testCompressInputAllDiffSegs() throws IOException {
    // The file will have all unique segments and thus only go into one section of if-statement (the
    // else, not the if)
    Segmentator seg = new Segmentator(2, "punctuation.txt");
    Segmentator.Test test = seg.new Test();

    List<String> segmentsToCompress = seg.segmentString();

    List<Integer> actualList = test.testCompressInput(segmentsToCompress);
    List<Integer> expectedList = new ArrayList<Integer>();
    expectedList.add(0);
    expectedList.add(1);
    expectedList.add(2);
    expectedList.add(3);

    assertEquals(expectedList, actualList);
  }