diff options
Diffstat (limited to 'searchlib/src/test/java/com/yahoo/searchlib/rankingexpression/FeatureListTestCase.java')
-rwxr-xr-x | searchlib/src/test/java/com/yahoo/searchlib/rankingexpression/FeatureListTestCase.java | 152 |
1 files changed, 76 insertions, 76 deletions
diff --git a/searchlib/src/test/java/com/yahoo/searchlib/rankingexpression/FeatureListTestCase.java b/searchlib/src/test/java/com/yahoo/searchlib/rankingexpression/FeatureListTestCase.java index 7399088ac1c..dfa726ecb8f 100755 --- a/searchlib/src/test/java/com/yahoo/searchlib/rankingexpression/FeatureListTestCase.java +++ b/searchlib/src/test/java/com/yahoo/searchlib/rankingexpression/FeatureListTestCase.java @@ -1,77 +1,77 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.searchlib.rankingexpression;
-
-import com.yahoo.searchlib.rankingexpression.parser.ParseException;
-import org.junit.Test;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.Reader;
-import java.io.StringReader;
-import java.util.Arrays;
-import java.util.List;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-/**
- * @author <a href="mailto:simon@yahoo-inc.com">Simon Thoresen</a>
- */
-public class FeatureListTestCase {
-
- @Test
- public void requireThatFeatureListFromStringWorks() throws ParseException {
- assertFromString("attribute(foo).out",
- Arrays.asList("attribute(foo).out"));
- assertFromString("attribute(foo).out attribute ( bar ) . out",
- Arrays.asList("attribute(foo).out", "attribute(bar).out"));
- assertFromString("foo\n bar\n \t \t \n baz \n",
- Arrays.asList("foo", "bar", "baz"));
- assertFromString("attribute attribute(foo) attribute(foo).out attribute(bar).out.out",
- Arrays.asList("attribute", "attribute(foo)", "attribute(foo).out", "attribute(bar).out.out"));
- }
-
- @Test
- public void requireThatFeatureListFromReaderWorks() throws ParseException {
- assertFromReader(new StringReader("attribute(foo).out"),
- Arrays.asList("attribute(foo).out"));
- assertFromReader(new StringReader("attribute(foo).out attribute ( bar ) . out"),
- Arrays.asList("attribute(foo).out", "attribute(bar).out"));
- assertFromReader(new StringReader("foo\n bar\n \t \t \n baz \n"),
- Arrays.asList("foo", "bar", "baz"));
- assertFromReader(new StringReader("attribute attribute(foo) attribute(foo).out attribute(bar).out.out"),
- Arrays.asList("attribute", "attribute(foo)", "attribute(foo).out", "attribute(bar).out.out"));
- }
-
- @Test
- public void requireThatFeatureListFromFileWorks() throws ParseException, FileNotFoundException {
- assertFromFile(new File("src/test/files/features01.expression"),
- Arrays.asList("attribute(foo).out"));
- assertFromFile(new File("src/test/files/features02.expression"),
- Arrays.asList("attribute(foo).out", "attribute(bar).out"));
- assertFromFile(new File("src/test/files/features03.expression"),
- Arrays.asList("foo", "bar", "baz"));
- assertFromFile(new File("src/test/files/features04.expression"),
- Arrays.asList("attribute", "attribute(foo)", "attribute(foo).out", "attribute(bar).out.out"));
- }
-
- public void assertFromString(String input, List<String> expected) throws ParseException {
- assertFeatureList(new FeatureList(input), expected);
- }
-
- public void assertFromReader(Reader input, List<String> expected) throws ParseException {
- assertFeatureList(new FeatureList(input), expected);
- }
-
- public void assertFromFile(File input, List<String> expected) throws ParseException, FileNotFoundException {
- assertFeatureList(new FeatureList(input), expected);
- }
-
- public void assertFeatureList(FeatureList features, List<String> expected) throws ParseException {
- assertEquals(expected.size(), features.size());
- for (int i = 0; i < features.size(); ++i) {
- assertTrue(features.get(i) != null);
- assertEquals(expected.get(i), features.get(i).toString());
- }
- }
-}
+package com.yahoo.searchlib.rankingexpression; + +import com.yahoo.searchlib.rankingexpression.parser.ParseException; +import org.junit.Test; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.Reader; +import java.io.StringReader; +import java.util.Arrays; +import java.util.List; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +/** + * @author <a href="mailto:simon@yahoo-inc.com">Simon Thoresen</a> + */ +public class FeatureListTestCase { + + @Test + public void requireThatFeatureListFromStringWorks() throws ParseException { + assertFromString("attribute(foo).out", + Arrays.asList("attribute(foo).out")); + assertFromString("attribute(foo).out attribute ( bar ) . out", + Arrays.asList("attribute(foo).out", "attribute(bar).out")); + assertFromString("foo\n bar\n \t \t \n baz \n", + Arrays.asList("foo", "bar", "baz")); + assertFromString("attribute attribute(foo) attribute(foo).out attribute(bar).out.out", + Arrays.asList("attribute", "attribute(foo)", "attribute(foo).out", "attribute(bar).out.out")); + } + + @Test + public void requireThatFeatureListFromReaderWorks() throws ParseException { + assertFromReader(new StringReader("attribute(foo).out"), + Arrays.asList("attribute(foo).out")); + assertFromReader(new StringReader("attribute(foo).out attribute ( bar ) . out"), + Arrays.asList("attribute(foo).out", "attribute(bar).out")); + assertFromReader(new StringReader("foo\n bar\n \t \t \n baz \n"), + Arrays.asList("foo", "bar", "baz")); + assertFromReader(new StringReader("attribute attribute(foo) attribute(foo).out attribute(bar).out.out"), + Arrays.asList("attribute", "attribute(foo)", "attribute(foo).out", "attribute(bar).out.out")); + } + + @Test + public void requireThatFeatureListFromFileWorks() throws ParseException, FileNotFoundException { + assertFromFile(new File("src/test/files/features01.expression"), + Arrays.asList("attribute(foo).out")); + assertFromFile(new File("src/test/files/features02.expression"), + Arrays.asList("attribute(foo).out", "attribute(bar).out")); + assertFromFile(new File("src/test/files/features03.expression"), + Arrays.asList("foo", "bar", "baz")); + assertFromFile(new File("src/test/files/features04.expression"), + Arrays.asList("attribute", "attribute(foo)", "attribute(foo).out", "attribute(bar).out.out")); + } + + public void assertFromString(String input, List<String> expected) throws ParseException { + assertFeatureList(new FeatureList(input), expected); + } + + public void assertFromReader(Reader input, List<String> expected) throws ParseException { + assertFeatureList(new FeatureList(input), expected); + } + + public void assertFromFile(File input, List<String> expected) throws ParseException, FileNotFoundException { + assertFeatureList(new FeatureList(input), expected); + } + + public void assertFeatureList(FeatureList features, List<String> expected) throws ParseException { + assertEquals(expected.size(), features.size()); + for (int i = 0; i < features.size(); ++i) { + assertTrue(features.get(i) != null); + assertEquals(expected.get(i), features.get(i).toString()); + } + } +} |