예제 #1
0
        public virtual void TestIntStream()
        {
            NumericTokenStream stream = (new NumericTokenStream()).SetInt32Value(ivalue);
            // use getAttribute to test if attributes really exist, if not an IAE will be throwed
            ITermToBytesRefAttribute bytesAtt = stream.GetAttribute <ITermToBytesRefAttribute>();
            ITypeAttribute           typeAtt  = stream.GetAttribute <ITypeAttribute>();

            NumericTokenStream.INumericTermAttribute numericAtt = stream.GetAttribute <NumericTokenStream.INumericTermAttribute>();
            BytesRef bytes = bytesAtt.BytesRef;

            stream.Reset();
            Assert.AreEqual(32, numericAtt.ValueSize);
            for (int shift = 0; shift < 32; shift += NumericUtils.PRECISION_STEP_DEFAULT)
            {
                Assert.IsTrue(stream.IncrementToken(), "New token is available");
                Assert.AreEqual(shift, numericAtt.Shift, "Shift value wrong");
                bytesAtt.FillBytesRef();
                Assert.AreEqual(ivalue & ~((1 << shift) - 1), NumericUtils.PrefixCodedToInt32(bytes), "Term is incorrectly encoded");
                Assert.AreEqual(((long)ivalue) & ~((1L << shift) - 1L), numericAtt.RawValue, "Term raw value is incorrectly encoded");
                Assert.AreEqual((shift == 0) ? NumericTokenStream.TOKEN_TYPE_FULL_PREC : NumericTokenStream.TOKEN_TYPE_LOWER_PREC, typeAtt.Type, "Type incorrect");
            }
            Assert.IsFalse(stream.IncrementToken(), "More tokens available");
            stream.End();
            stream.Dispose();
        }
예제 #2
0
        public virtual void TestNotInitialized()
        {
            NumericTokenStream stream = new NumericTokenStream();

            try
            {
                stream.Reset();
                Assert.Fail("reset() should not succeed.");
            }
            catch (Exception e) when(e.IsIllegalStateException())
            {
                // pass
            }

            try
            {
                stream.IncrementToken();
                Assert.Fail("IncrementToken() should not succeed.");
            }
            catch (Exception e) when(e.IsIllegalStateException())
            {
                // pass
            }
        }
예제 #3
0
        public virtual void  TestNotInitialized()
        {
            NumericTokenStream stream = new NumericTokenStream();

            try
            {
                stream.Reset();
                Assert.Fail("reset() should not succeed.");
            }
            catch (System.SystemException e)
            {
                // pass
            }

            try
            {
                stream.IncrementToken();
                Assert.Fail("incrementToken() should not succeed.");
            }
            catch (System.SystemException e)
            {
                // pass
            }
        }
예제 #4
0
		public virtual void  TestNotInitialized()
		{
			NumericTokenStream stream = new NumericTokenStream();
			
			try
			{
				stream.Reset();
				Assert.Fail("reset() should not succeed.");
			}
			catch (System.SystemException e)
			{
				// pass
			}
			
			try
			{
				stream.IncrementToken();
				Assert.Fail("incrementToken() should not succeed.");
			}
			catch (System.SystemException e)
			{
				// pass
			}
		}