예제 #1
0
        public void TestUnicodeSeparator()
        {
            DictionaryMetadata m = DictionaryMetadata.Read(GetType().getResourceAsStream("unicode-separator.info"));

            //Assertions.assertThat(m.getSeparator()).isEqualTo((byte) '\t');
            Assert.AreEqual((byte)'\t', m.Separator);
        }
예제 #2
0
        public void TestWriteMetadata()
        {
            StringWriter sw = new StringWriter();

            EncoderType encoder  = randomFrom((EncoderType[])Enum.GetValues(typeof(EncoderType)));
            var         encoding = randomFrom(new Encoding[] {
                Encoding.UTF8,
                Encoding.GetEncoding("iso-8859-1"),
                Encoding.ASCII
            });

            //Charset encoding = randomFrom(Arrays.asList(
            //    StandardCharsets.UTF_8,
            //    StandardCharsets.ISO_8859_1,
            //    StandardCharsets.US_ASCII));

            DictionaryMetadata.Builder()
            .Encoding(encoding)
            .Encoder(encoder)
            .Separator('|')
            .Build()
            .Write(sw);

            DictionaryMetadata other =
                DictionaryMetadata.Read(new MemoryStream(Encoding.UTF8.GetBytes(sw.ToString())));

            //Assertions.assertThat(other.getSeparator()).isEqualTo((byte) '|');
            //Assertions.assertThat(other.getDecoder().charset()).isEqualTo(encoding);
            //Assertions.assertThat(other.getEncoder().charset()).isEqualTo(encoding);
            //Assertions.assertThat(other.getSequenceEncoderType()).isEqualTo(encoder);
            Assert.AreEqual((byte)'|', other.Separator);
            Assert.AreEqual(encoding, other.Decoder);
            Assert.AreEqual(encoding, other.Encoder);
            Assert.AreEqual(encoder, other.SequenceEncoderType);
        }
예제 #3
0
 /// <summary>
 /// Attempts to load a dictionary from opened streams of FSA dictionary data
 /// and associated metadata. Input streams are not disposed automatically.
 /// </summary>
 /// <param name="fsaStream">The stream with FSA data.</param>
 /// <param name="metadataStream">The stream with metadata.</param>
 /// <returns>Returns an instantiated <see cref="Dictionary"/>.</returns>
 /// <exception cref="IOException">IOException if an I/O error occurs.</exception>
 public static Dictionary Read(Stream fsaStream, Stream metadataStream)
 {
     return(new Dictionary(FSA.Read(fsaStream), DictionaryMetadata.Read(metadataStream)));
 }