mirror of https://github.com/Squidex/squidex.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.7 KiB
55 lines
1.7 KiB
// ==========================================================================
|
|
// Squidex Headless CMS
|
|
// ==========================================================================
|
|
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
|
// All rights reserved. Licensed under the MIT license.
|
|
// ==========================================================================
|
|
|
|
using Lucene.Net.Analysis.Standard;
|
|
using Lucene.Net.Documents;
|
|
using Lucene.Net.Index;
|
|
using Lucene.Net.Store;
|
|
using Lucene.Net.Util;
|
|
using Xunit;
|
|
|
|
namespace Squidex.Domain.Apps.Entities.Contents.Text
|
|
{
|
|
public class DocValuesTests
|
|
{
|
|
[Fact]
|
|
public void Should_read_and_write_doc_values()
|
|
{
|
|
var version = LuceneVersion.LUCENE_48;
|
|
|
|
var indexWriter =
|
|
new IndexWriter(new RAMDirectory(),
|
|
new IndexWriterConfig(version, new StandardAnalyzer(version)));
|
|
|
|
using (indexWriter)
|
|
{
|
|
for (byte i = 0; i < 255; i++)
|
|
{
|
|
var document = new Document();
|
|
|
|
document.AddBinaryDocValuesField("field", new BytesRef(new[] { i }));
|
|
|
|
indexWriter.AddDocument(document);
|
|
}
|
|
|
|
indexWriter.Commit();
|
|
|
|
using (var reader = indexWriter.GetReader(true))
|
|
{
|
|
var bytesRef = new BytesRef(1);
|
|
|
|
for (byte i = 0; i < 255; i++)
|
|
{
|
|
reader.GetBinaryValue("field", i, bytesRef);
|
|
|
|
Assert.Equal(i, bytesRef.Bytes[0]);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|