AssertCopyIsEqual() public static method

public static AssertCopyIsEqual ( Lucene.Net.Util.Attribute att ) : Lucene.Net.Util.Attribute
att Lucene.Net.Util.Attribute
return Lucene.Net.Util.Attribute
Example #1
0
        public virtual void  TestCopyTo()
        {
            TermAttribute t    = new TermAttribute();
            TermAttribute copy = (TermAttribute)TestSimpleAttributeImpls.AssertCopyIsEqual(t);

            Assert.AreEqual("", t.Term);
            Assert.AreEqual("", copy.Term);

            t = new TermAttribute();
            char[] content = "hello".ToCharArray();
            t.SetTermBuffer(content, 0, 5);
            char[] buf = t.TermBuffer();
            copy = (TermAttribute)TestSimpleAttributeImpls.AssertCopyIsEqual(t);
            Assert.AreEqual(t.Term, copy.Term);
            Assert.AreNotSame(buf, copy.TermBuffer());
        }
Example #2
0
        public virtual void  TestCopyTo()
        {
            Token t    = new Token();
            Token copy = (Token)TestSimpleAttributeImpls.AssertCopyIsEqual(t);

            Assert.AreEqual("", t.Term);
            Assert.AreEqual("", copy.Term);

            t = new Token(0, 5);
            char[] content = "hello".ToCharArray();
            t.SetTermBuffer(content, 0, 5);
            char[] buf = t.TermBuffer();
            copy = (Token)TestSimpleAttributeImpls.AssertCopyIsEqual(t);
            Assert.AreEqual(t.Term, copy.Term);
            Assert.AreNotSame(buf, copy.TermBuffer());

            Payload pl = new Payload(new byte[] { 1, 2, 3, 4 });

            t.Payload = pl;
            copy      = (Token)TestSimpleAttributeImpls.AssertCopyIsEqual(t);
            Assert.AreEqual(pl, copy.Payload);
            Assert.AreNotSame(pl, copy.Payload);
        }