/// <summary> /// Decodes a previously encoded <see cref="float"/>. /// <para/> /// NOTE: This was bytesRefToFloat() in Lucene /// </summary> public static float BytesRefToSingle(BytesRef b) { return(J2N.BitConversion.Int32BitsToSingle(Int32AssociationFacetField.BytesRefToInt32(b))); }
/// <summary> /// Encodes a <see cref="float"/> as a 4-byte <see cref="BytesRef"/>. /// <para/> /// NOTE: This was floatToBytesRef() in Lucene /// </summary> public static BytesRef SingleToBytesRef(float v) { return(Int32AssociationFacetField.Int32ToBytesRef(J2N.BitConversion.SingleToInt32Bits(v))); }
/// <summary> /// Decodes a previously encoded <see cref="float"/>. /// <para/> /// NOTE: This was bytesRefToFloat() in Lucene /// </summary> public static float BytesRefToSingle(BytesRef b) { return(Support.Number.Int32BitsToSingle(Int32AssociationFacetField.BytesRefToInt32(b))); }
public virtual void TestEmptyNullComponents() { // LUCENE-4724: CategoryPath should not allow empty or null components string[][] components_tests = new string[][] { new string[] { "", "test" }, // empty in the beginning new string[] { "test", "" }, // empty in the end new string[] { "test", "", "foo" }, // empty in the middle new string[] { null, "test" }, // null at the beginning new string[] { "test", null }, // null in the end new string[] { "test", null, "foo" } // null in the middle }; foreach (string[] components in components_tests) { try { Assert.IsNotNull(new FacetLabel(components)); fail("empty or null components should not be allowed: " + Arrays.ToString(components)); } catch (Exception e) when(e.IsIllegalArgumentException()) { // expected } try { _ = new FacetField("dim", components); fail("empty or null components should not be allowed: " + Arrays.ToString(components)); } catch (Exception e) when(e.IsIllegalArgumentException()) { // expected } try { _ = new AssociationFacetField(new BytesRef(), "dim", components); fail("empty or null components should not be allowed: " + Arrays.ToString(components)); } catch (Exception e) when(e.IsIllegalArgumentException()) { // expected } try { _ = new Int32AssociationFacetField(17, "dim", components); fail("empty or null components should not be allowed: " + Arrays.ToString(components)); } catch (Exception e) when(e.IsIllegalArgumentException()) { // expected } try { _ = new SingleAssociationFacetField(17.0f, "dim", components); fail("empty or null components should not be allowed: " + Arrays.ToString(components)); } catch (Exception e) when(e.IsIllegalArgumentException()) { // expected } } try { _ = new FacetField(null, new string[] { "abc" }); fail("empty or null components should not be allowed"); } catch (Exception e) when(e.IsIllegalArgumentException()) { // expected } try { _ = new FacetField("", new string[] { "abc" }); fail("empty or null components should not be allowed"); } catch (Exception e) when(e.IsIllegalArgumentException()) { // expected } try { _ = new Int32AssociationFacetField(17, null, new string[] { "abc" }); fail("empty or null components should not be allowed"); } catch (Exception e) when(e.IsIllegalArgumentException()) { // expected } try { _ = new Int32AssociationFacetField(17, "", new string[] { "abc" }); fail("empty or null components should not be allowed"); } catch (Exception e) when(e.IsIllegalArgumentException()) { // expected } try { _ = new SingleAssociationFacetField(17.0f, null, new string[] { "abc" }); fail("empty or null components should not be allowed"); } catch (Exception e) when(e.IsIllegalArgumentException()) { // expected } try { _ = new SingleAssociationFacetField(17.0f, "", new string[] { "abc" }); fail("empty or null components should not be allowed"); } catch (Exception e) when(e.IsIllegalArgumentException()) { // expected } try { _ = new AssociationFacetField(new BytesRef(), null, new string[] { "abc" }); fail("empty or null components should not be allowed"); } catch (Exception e) when(e.IsIllegalArgumentException()) { // expected } try { _ = new AssociationFacetField(new BytesRef(), "", new string[] { "abc" }); fail("empty or null components should not be allowed"); } catch (Exception e) when(e.IsIllegalArgumentException()) { // expected } try { _ = new SortedSetDocValuesFacetField(null, "abc"); fail("empty or null components should not be allowed"); } catch (Exception e) when(e.IsIllegalArgumentException()) { // expected } try { _ = new SortedSetDocValuesFacetField("", "abc"); fail("empty or null components should not be allowed"); } catch (Exception e) when(e.IsIllegalArgumentException()) { // expected } try { _ = new SortedSetDocValuesFacetField("dim", null); fail("empty or null components should not be allowed"); } catch (Exception e) when(e.IsIllegalArgumentException()) { // expected } try { _ = new SortedSetDocValuesFacetField("dim", ""); fail("empty or null components should not be allowed"); } catch (Exception e) when(e.IsIllegalArgumentException()) { // expected } }
/// <summary> /// Encodes a <see cref="float"/> as a 4-byte <see cref="BytesRef"/>. /// <para/> /// NOTE: This was floatToBytesRef() in Lucene /// </summary> public static BytesRef SingleToBytesRef(float v) { return(Int32AssociationFacetField.Int32ToBytesRef(Support.Number.SingleToInt32Bits(v))); }