### Question:
LmVocabulary { public boolean contains(int index) { return index >= 0 && index < vocabulary.size(); } LmVocabulary(String... vocabulary);  LmVocabulary(List<String> vocabulary); private  LmVocabulary(RandomAccessFile raf); private  LmVocabulary(DataInputStream dis); static LmVocabulary loadFromBinary(File binaryVocabularyFile); static LmVocabulary loadFromBinary(Path binaryVocabularyFilePath); static LmVocabulary loadFromRandomAccessFile(RandomAccessFile raf); static LmVocabulary loadFromDataInputStream(DataInputStream dis); static LmVocabulary loadFromUtf8File(File utfVocabularyFile); static Builder builder(); static LmVocabulary intersect(LmVocabulary v1, LmVocabulary v2); void saveBinary(File file); void saveBinary(DataOutputStream dos); int size(); boolean containsUnknown(int... gramIds); boolean containsSuffix(); boolean containsPrefix(); String getWord(int index); int indexOf(String word); int getSentenceStartIndex(); int getSentenceEndIndex(); int getUnknownWordIndex(); String getUnknownWord(); String getSentenceStart(); String getSentenceEnd(); Iterable<Integer> alphabeticallySortedWordsIds(Locale locale); Iterable<Integer> alphabeticallySortedWordsIds(); Iterable<String> words(); Iterable<String> wordsSorted(); Iterable<String> wordsSorted(Locale locale); String getWordsString(int... indexes); boolean containsAll(int... indexes); boolean contains(int index); boolean containsAll(String... words); boolean contains(String word); long encodeTrigram(int g0, int g1, int g2); long encodeTrigram(int... triGram); int[] toIndexes(String... words); int[] toIndexes(String[] history, String word); int[] toIndexes(int[] history, String word); String[] toWords(int... indexes); static final String DEFAULT_SENTENCE_BEGIN_MARKER; static final String DEFAULT_SENTENCE_END_MARKER; static final String DEFAULT_UNKNOWN_WORD; }### Answer:
@Test public void contains() throws IOException { LmVocabulary vocabulary = new LmVocabulary("Hello", "World"); int helloIndex = vocabulary.indexOf("Hello"); int worldIndex = vocabulary.indexOf("World"); Assert.assertTrue(vocabulary.contains(helloIndex)); Assert.assertTrue(vocabulary.contains(worldIndex)); int unkIndex = vocabulary.indexOf("Foo"); Assert.assertEquals(vocabulary.getUnknownWordIndex(), unkIndex); Assert.assertTrue(vocabulary.containsAll(helloIndex, worldIndex)); Assert.assertFalse(vocabulary.containsAll(-1, 2)); Assert.assertTrue(vocabulary.contains("Hello")); Assert.assertTrue(vocabulary.contains("World")); Assert.assertFalse(vocabulary.contains("Foo")); Assert.assertFalse(vocabulary.containsAll("Hello", "Foo")); Assert.assertTrue(vocabulary.containsAll("Hello", "World")); }