Skip to content

Commit

Permalink
replaceNewlinesWithSpacesTest=true unit test for @Craigacp
Browse files Browse the repository at this point in the history
  • Loading branch information
nezda committed Apr 28, 2021
1 parent d8347af commit 4175623
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions Data/src/test/java/org/tribuo/data/columnar/RowProcessorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,8 @@ public void replaceNewlinesWithSpacesTest() {
Example<MockOutput> example = processor.generateExample(row,true).get();

// Check example is extracted correctly
assertEquals(5,example.size());
assertEquals("Sheep",example.getOutput().label);
assertEquals(5, example.size());
assertEquals("Sheep", example.getOutput().label);
Iterator<Feature> featureIterator = example.iterator();
Feature a = featureIterator.next();
assertEquals("order_text@1-N=*", a.getName());
Expand All @@ -226,6 +226,26 @@ public void replaceNewlinesWithSpacesTest() {
a = featureIterator.next();
assertEquals("order_text@2-N=Jimmy/*", a.getName());
assertFalse(featureIterator.hasNext());

// same input with replaceNewlinesWithSpacesTest=true (the default) produces different features
processor = new RowProcessor<>(Collections.emptyList(),null,response,fieldProcessors,Collections.emptyMap(),Collections.emptySet(), true);

example = processor.generateExample(row,true).get();

// Check example is extracted correctly
assertEquals(3, example.size());
assertEquals("Sheep", example.getOutput().label);
featureIterator = example.iterator();
a = featureIterator.next();
assertEquals("order_text@1-N=Hoffa", a.getName());
assertEquals(1.0, a.getValue());
a = featureIterator.next();
assertEquals("order_text@1-N=Jimmy", a.getName());
a = featureIterator.next();
assertEquals("order_text@2-N=Jimmy/Hoffa", a.getName());
a = featureIterator.next(); // doesn't throw NoSuchElementException?
assertNull(a.getName());
assertFalse(featureIterator.hasNext());
}

static class MungingTokenizer implements Tokenizer {
Expand Down

0 comments on commit 4175623

Please sign in to comment.