public virtual void TestBasicsRngCollating() { System.Globalization.CompareInfo c = new System.Globalization.CultureInfo("en").CompareInfo; QueryUtils.Check(Csrq("data", "1", "6", T, T, c)); QueryUtils.Check(Csrq("data", "A", "Z", T, T, c)); QueryUtils.CheckUnequal(Csrq("data", "1", "6", T, T, c), Csrq("data", "A", "Z", T, T, c)); }
public virtual void TestEqualsAndHash() { QueryUtils.CheckHashEquals(NumericRangeQuery.NewIntRange("test1", 4, 10, 20, true, true)); QueryUtils.CheckHashEquals(NumericRangeQuery.NewIntRange("test2", 4, 10, 20, false, true)); QueryUtils.CheckHashEquals(NumericRangeQuery.NewIntRange("test3", 4, 10, 20, true, false)); QueryUtils.CheckHashEquals(NumericRangeQuery.NewIntRange("test4", 4, 10, 20, false, false)); QueryUtils.CheckHashEquals(NumericRangeQuery.NewIntRange("test5", 4, 10, null, true, true)); QueryUtils.CheckHashEquals(NumericRangeQuery.NewIntRange("test6", 4, null, 20, true, true)); QueryUtils.CheckHashEquals(NumericRangeQuery.NewIntRange("test7", 4, null, null, true, true)); QueryUtils.CheckEqual(NumericRangeQuery.NewIntRange("test8", 4, 10, 20, true, true), NumericRangeQuery.NewIntRange("test8", 4, 10, 20, true, true)); QueryUtils.CheckUnequal(NumericRangeQuery.NewIntRange("test9", 4, 10, 20, true, true), NumericRangeQuery.NewIntRange("test9", 8, 10, 20, true, true)); QueryUtils.CheckUnequal(NumericRangeQuery.NewIntRange("test10a", 4, 10, 20, true, true), NumericRangeQuery.NewIntRange("test10b", 4, 10, 20, true, true)); QueryUtils.CheckUnequal(NumericRangeQuery.NewIntRange("test11", 4, 10, 20, true, true), NumericRangeQuery.NewIntRange("test11", 4, 20, 10, true, true)); QueryUtils.CheckUnequal(NumericRangeQuery.NewIntRange("test12", 4, 10, 20, true, true), NumericRangeQuery.NewIntRange("test12", 4, 10, 20, false, true)); QueryUtils.CheckUnequal(NumericRangeQuery.NewIntRange("test13", 4, 10, 20, true, true), NumericRangeQuery.NewFloatRange("test13", 4, 10f, 20f, true, true)); // the following produces a hash collision, because Long and Integer have the same hashcode, so only test equality: Query q1 = NumericRangeQuery.NewIntRange("test14", 4, 10, 20, true, true); Query q2 = NumericRangeQuery.NewLongRange("test14", 4, 10L, 20L, true, true); Assert.IsFalse(q1.Equals(q2)); Assert.IsFalse(q2.Equals(q1)); }
public virtual void TestEqualsAndHash() { QueryUtils.CheckHashEquals(NumericRangeQuery.NewLongRange("test1", 4, 10L, 20L, true, true)); QueryUtils.CheckHashEquals(NumericRangeQuery.NewLongRange("test2", 4, 10L, 20L, false, true)); QueryUtils.CheckHashEquals(NumericRangeQuery.NewLongRange("test3", 4, 10L, 20L, true, false)); System.Int64 tempAux7 = 10L; QueryUtils.CheckHashEquals(NumericRangeQuery.NewLongRange("test4", 4, 10L, 20L, false, false)); QueryUtils.CheckHashEquals(NumericRangeQuery.NewLongRange("test5", 4, 10L, null, true, true)); QueryUtils.CheckHashEquals(NumericRangeQuery.NewLongRange("test6", 4, null, 20L, true, true)); QueryUtils.CheckHashEquals(NumericRangeQuery.NewLongRange("test7", 4, null, null, true, true)); QueryUtils.CheckEqual(NumericRangeQuery.NewLongRange("test8", 4, 10L, 20L, true, true), NumericRangeQuery.NewLongRange("test8", 4, 10L, 20L, true, true)); QueryUtils.CheckUnequal(NumericRangeQuery.NewLongRange("test9", 4, 10L, 20L, true, true), NumericRangeQuery.NewLongRange("test9", 8, 10L, 20L, true, true)); QueryUtils.CheckUnequal(NumericRangeQuery.NewLongRange("test10a", 4, 10L, 20L, true, true), NumericRangeQuery.NewLongRange("test10b", 4, 10L, 20L, true, true)); QueryUtils.CheckUnequal(NumericRangeQuery.NewLongRange("test11", 4, 10L, 20L, true, true), NumericRangeQuery.NewLongRange("test11", 4, 20L, 10L, true, true)); QueryUtils.CheckUnequal(NumericRangeQuery.NewLongRange("test12", 4, 10L, 20L, true, true), NumericRangeQuery.NewLongRange("test12", 4, 10L, 20L, false, true)); QueryUtils.CheckUnequal(NumericRangeQuery.NewLongRange("test13", 4, 10L, 20L, true, true), NumericRangeQuery.NewFloatRange("test13", 4, 10f, 20f, true, true)); // difference to int range is tested in TestNumericRangeQuery32 }
public virtual void TestEqualsAndHash() { System.Int64 tempAux = 10L; System.Int64 tempAux2 = 20L; QueryUtils.CheckHashEquals(NumericRangeQuery.NewLongRange("test1", 4, tempAux, tempAux2, true, true)); System.Int64 tempAux3 = 10L; System.Int64 tempAux4 = 20L; QueryUtils.CheckHashEquals(NumericRangeQuery.NewLongRange("test2", 4, tempAux3, tempAux4, false, true)); System.Int64 tempAux5 = 10L; System.Int64 tempAux6 = 20L; QueryUtils.CheckHashEquals(NumericRangeQuery.NewLongRange("test3", 4, tempAux5, tempAux6, true, false)); System.Int64 tempAux7 = 10L; System.Int64 tempAux8 = 20L; QueryUtils.CheckHashEquals(NumericRangeQuery.NewLongRange("test4", 4, tempAux7, tempAux8, false, false)); //UPGRADE_TODO: The 'System.Int64' structure does not have an equivalent to NULL. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1291'" System.Int64 tempAux9 = 10L; QueryUtils.CheckHashEquals(NumericRangeQuery.NewLongRange("test5", 4, tempAux9, null, true, true)); //UPGRADE_TODO: The 'System.Int64' structure does not have an equivalent to NULL. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1291'" System.Int64 tempAux10 = 20L; QueryUtils.CheckHashEquals(NumericRangeQuery.NewLongRange("test6", 4, null, tempAux10, true, true)); //UPGRADE_TODO: The 'System.Int64' structure does not have an equivalent to NULL. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1291'" QueryUtils.CheckHashEquals(NumericRangeQuery.NewLongRange("test7", 4, null, null, true, true)); System.Int64 tempAux11 = 10L; System.Int64 tempAux12 = 20L; System.Int64 tempAux13 = 10L; System.Int64 tempAux14 = 20L; QueryUtils.CheckEqual(NumericRangeQuery.NewLongRange("test8", 4, tempAux11, tempAux12, true, true), NumericRangeQuery.NewLongRange("test8", 4, tempAux13, tempAux14, true, true)); System.Int64 tempAux15 = 10L; System.Int64 tempAux16 = 20L; System.Int64 tempAux17 = 10L; System.Int64 tempAux18 = 20L; QueryUtils.CheckUnequal(NumericRangeQuery.NewLongRange("test9", 4, tempAux15, tempAux16, true, true), NumericRangeQuery.NewLongRange("test9", 8, tempAux17, tempAux18, true, true)); System.Int64 tempAux19 = 10L; System.Int64 tempAux20 = 20L; System.Int64 tempAux21 = 10L; System.Int64 tempAux22 = 20L; QueryUtils.CheckUnequal(NumericRangeQuery.NewLongRange("test10a", 4, tempAux19, tempAux20, true, true), NumericRangeQuery.NewLongRange("test10b", 4, tempAux21, tempAux22, true, true)); System.Int64 tempAux23 = 10L; System.Int64 tempAux24 = 20L; System.Int64 tempAux25 = 20L; System.Int64 tempAux26 = 10L; QueryUtils.CheckUnequal(NumericRangeQuery.NewLongRange("test11", 4, tempAux23, tempAux24, true, true), NumericRangeQuery.NewLongRange("test11", 4, tempAux25, tempAux26, true, true)); System.Int64 tempAux27 = 10L; System.Int64 tempAux28 = 20L; System.Int64 tempAux29 = 10L; System.Int64 tempAux30 = 20L; QueryUtils.CheckUnequal(NumericRangeQuery.NewLongRange("test12", 4, tempAux27, tempAux28, true, true), NumericRangeQuery.NewLongRange("test12", 4, tempAux29, tempAux30, false, true)); System.Int64 tempAux31 = 10L; System.Int64 tempAux32 = 20L; System.Single tempAux33 = (float)10f; System.Single tempAux34 = (float)20f; QueryUtils.CheckUnequal(NumericRangeQuery.NewLongRange("test13", 4, tempAux31, tempAux32, true, true), NumericRangeQuery.NewFloatRange("test13", 4, tempAux33, tempAux34, true, true)); // difference to int range is tested in TestNumericRangeQuery32 }
public virtual void TestBasics() { QueryUtils.Check(Csrq("data", "1", "6", T, T)); QueryUtils.Check(Csrq("data", "A", "Z", T, T)); QueryUtils.CheckUnequal(Csrq("data", "1", "6", T, T), Csrq("data", "A", "Z", T, T)); QueryUtils.Check(Cspq(new Term("data", "p*u?"))); QueryUtils.CheckUnequal(Cspq(new Term("data", "pre*")), Cspq(new Term("data", "pres*"))); QueryUtils.Check(Cswcq(new Term("data", "p"))); QueryUtils.CheckUnequal(Cswcq(new Term("data", "pre*n?t")), Cswcq(new Term("data", "pr*t?j"))); }
public virtual void TestEqualsHashcode() { // some tests before, if the used queries and filters work: Assert.AreEqual(new PrefixFilter(new Term("field", "o")), new PrefixFilter(new Term("field", "o"))); Assert.IsFalse((new PrefixFilter(new Term("field", "a"))).Equals(new PrefixFilter(new Term("field", "o")))); QueryUtils.CheckHashEquals(new TermQuery(new Term("field", "one"))); QueryUtils.CheckUnequal(new TermQuery(new Term("field", "one")), new TermQuery(new Term("field", "two")) ); // now test FilteredQuery equals/hashcode: QueryUtils.CheckHashEquals(new FilteredQuery(new TermQuery(new Term("field", "one")), new PrefixFilter(new Term("field", "o")))); QueryUtils.CheckUnequal(new FilteredQuery(new TermQuery(new Term("field", "one")), new PrefixFilter(new Term("field", "o"))), new FilteredQuery(new TermQuery(new Term("field", "two")), new PrefixFilter(new Term("field", "o"))) ); QueryUtils.CheckUnequal(new FilteredQuery(new TermQuery(new Term("field", "one")), new PrefixFilter(new Term("field", "a"))), new FilteredQuery(new TermQuery(new Term("field", "one")), new PrefixFilter(new Term("field", "o"))) ); }
public virtual void TestCSQ() { Query q1 = new ConstantScoreQuery(new TermQuery(new Term("a", "b"))); Query q2 = new ConstantScoreQuery(new TermQuery(new Term("a", "c"))); Query q3 = new ConstantScoreQuery(TermRangeFilter.NewStringRange("a", "b", "c", true, true)); QueryUtils.Check(q1); QueryUtils.Check(q2); QueryUtils.CheckEqual(q1, q1); QueryUtils.CheckEqual(q2, q2); QueryUtils.CheckEqual(q3, q3); QueryUtils.CheckUnequal(q1, q2); QueryUtils.CheckUnequal(q2, q3); QueryUtils.CheckUnequal(q1, q3); QueryUtils.CheckUnequal(q1, new TermQuery(new Term("a", "b"))); }
public virtual void TestEqualsAndHash() { System.Int32 tempAux = 10; System.Int32 tempAux2 = 20; QueryUtils.CheckHashEquals(NumericRangeQuery.NewIntRange("test1", 4, tempAux, tempAux2, true, true)); System.Int32 tempAux3 = 10; System.Int32 tempAux4 = 20; QueryUtils.CheckHashEquals(NumericRangeQuery.NewIntRange("test2", 4, tempAux3, tempAux4, false, true)); System.Int32 tempAux5 = 10; System.Int32 tempAux6 = 20; QueryUtils.CheckHashEquals(NumericRangeQuery.NewIntRange("test3", 4, tempAux5, tempAux6, true, false)); System.Int32 tempAux7 = 10; System.Int32 tempAux8 = 20; QueryUtils.CheckHashEquals(NumericRangeQuery.NewIntRange("test4", 4, tempAux7, tempAux8, false, false)); //UPGRADE_TODO: The 'System.Int32' structure does not have an equivalent to NULL. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1291'" System.Int32 tempAux9 = 10; QueryUtils.CheckHashEquals(NumericRangeQuery.NewIntRange("test5", 4, tempAux9, null, true, true)); //UPGRADE_TODO: The 'System.Int32' structure does not have an equivalent to NULL. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1291'" System.Int32 tempAux10 = 20; QueryUtils.CheckHashEquals(NumericRangeQuery.NewIntRange("test6", 4, null, tempAux10, true, true)); //UPGRADE_TODO: The 'System.Int32' structure does not have an equivalent to NULL. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1291'" QueryUtils.CheckHashEquals(NumericRangeQuery.NewIntRange("test7", 4, null, null, true, true)); System.Int32 tempAux11 = 10; System.Int32 tempAux12 = 20; System.Int32 tempAux13 = 10; System.Int32 tempAux14 = 20; QueryUtils.CheckEqual(NumericRangeQuery.NewIntRange("test8", 4, tempAux11, tempAux12, true, true), NumericRangeQuery.NewIntRange("test8", 4, tempAux13, tempAux14, true, true)); System.Int32 tempAux15 = 10; System.Int32 tempAux16 = 20; System.Int32 tempAux17 = 10; System.Int32 tempAux18 = 20; QueryUtils.CheckUnequal(NumericRangeQuery.NewIntRange("test9", 4, tempAux15, tempAux16, true, true), NumericRangeQuery.NewIntRange("test9", 8, tempAux17, tempAux18, true, true)); System.Int32 tempAux19 = 10; System.Int32 tempAux20 = 20; System.Int32 tempAux21 = 10; System.Int32 tempAux22 = 20; QueryUtils.CheckUnequal(NumericRangeQuery.NewIntRange("test10a", 4, tempAux19, tempAux20, true, true), NumericRangeQuery.NewIntRange("test10b", 4, tempAux21, tempAux22, true, true)); System.Int32 tempAux23 = 10; System.Int32 tempAux24 = 20; System.Int32 tempAux25 = 20; System.Int32 tempAux26 = 10; QueryUtils.CheckUnequal(NumericRangeQuery.NewIntRange("test11", 4, tempAux23, tempAux24, true, true), NumericRangeQuery.NewIntRange("test11", 4, tempAux25, tempAux26, true, true)); System.Int32 tempAux27 = 10; System.Int32 tempAux28 = 20; System.Int32 tempAux29 = 10; System.Int32 tempAux30 = 20; QueryUtils.CheckUnequal(NumericRangeQuery.NewIntRange("test12", 4, tempAux27, tempAux28, true, true), NumericRangeQuery.NewIntRange("test12", 4, tempAux29, tempAux30, false, true)); System.Int32 tempAux31 = 10; System.Int32 tempAux32 = 20; System.Single tempAux33 = (float)10f; System.Single tempAux34 = (float)20f; QueryUtils.CheckUnequal(NumericRangeQuery.NewIntRange("test13", 4, tempAux31, tempAux32, true, true), NumericRangeQuery.NewFloatRange("test13", 4, tempAux33, tempAux34, true, true)); // the following produces a hash collision, because Long and Integer have the same hashcode, so only test equality: System.Int32 tempAux35 = 10; System.Int32 tempAux36 = 20; Query q1 = NumericRangeQuery.NewIntRange("test14", 4, tempAux35, tempAux36, true, true); System.Int64 tempAux37 = 10L; System.Int64 tempAux38 = 20L; Query q2 = NumericRangeQuery.NewLongRange("test14", 4, tempAux37, tempAux38, true, true); Assert.IsFalse(q1.Equals(q2)); Assert.IsFalse(q2.Equals(q1)); }