Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id BCD3E200B9F for ; Tue, 11 Oct 2016 20:34:49 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id BBBB5160B0C; Tue, 11 Oct 2016 18:34:49 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id D7AE6160AFB for ; Tue, 11 Oct 2016 20:34:47 +0200 (CEST) Received: (qmail 80457 invoked by uid 500); 11 Oct 2016 18:34:47 -0000 Mailing-List: contact commits-help@lucenenet.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: lucene-net-dev@lucenenet.apache.org Delivered-To: mailing list commits@lucenenet.apache.org Received: (qmail 79728 invoked by uid 99); 11 Oct 2016 18:34:46 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 11 Oct 2016 18:34:46 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 3230DE3839; Tue, 11 Oct 2016 18:34:46 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: nightowl888@apache.org To: commits@lucenenet.apache.org Date: Tue, 11 Oct 2016 18:34:54 -0000 Message-Id: <4947cffb97ad49b598716ade88aecf5a@git.apache.org> In-Reply-To: <9fcbf2425c8a410082c11f25b6591c49@git.apache.org> References: <9fcbf2425c8a410082c11f25b6591c49@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [09/47] lucenenet git commit: Codecs.SimpleText.SimpleTextStoredFieldsWriter: Fixed formatting bugs that were causing loss of precision on float/double types when converting to string. archived-at: Tue, 11 Oct 2016 18:34:49 -0000 Codecs.SimpleText.SimpleTextStoredFieldsWriter: Fixed formatting bugs that were causing loss of precision on float/double types when converting to string. Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/f5cebafd Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/f5cebafd Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/f5cebafd Branch: refs/heads/master Commit: f5cebafd057f4f7a59377ae68603892609982d0e Parents: 450e647 Author: Shad Storhaug Authored: Sat Oct 8 16:21:05 2016 +0700 Committer: Shad Storhaug Committed: Sat Oct 8 17:15:42 2016 +0700 ---------------------------------------------------------------------- .../SimpleText/SimpleTextStoredFieldsWriter.cs | 13 ++++++++----- .../Index/BaseStoredFieldsFormatTestCase.cs | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/lucenenet/blob/f5cebafd/src/Lucene.Net.Codecs/SimpleText/SimpleTextStoredFieldsWriter.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Codecs/SimpleText/SimpleTextStoredFieldsWriter.cs b/src/Lucene.Net.Codecs/SimpleText/SimpleTextStoredFieldsWriter.cs index 7f0fb50..ebfc9b5 100644 --- a/src/Lucene.Net.Codecs/SimpleText/SimpleTextStoredFieldsWriter.cs +++ b/src/Lucene.Net.Codecs/SimpleText/SimpleTextStoredFieldsWriter.cs @@ -19,6 +19,7 @@ namespace Lucene.Net.Codecs.SimpleText { using System; + using System.Globalization; using FieldInfo = Index.FieldInfo; using FieldInfos = Index.FieldInfos; @@ -98,7 +99,7 @@ namespace Lucene.Net.Codecs.SimpleText public override void WriteField(FieldInfo info, IndexableField field) { Write(FIELD); - Write(Convert.ToString(info.Number)); + Write(info.Number.ToString(CultureInfo.InvariantCulture)); NewLine(); Write(NAME); @@ -117,7 +118,7 @@ namespace Lucene.Net.Codecs.SimpleText NewLine(); Write(VALUE); - Write(Convert.ToString((int) n)); + Write(((int)n).ToString(CultureInfo.InvariantCulture)); NewLine(); } else if (n is long?) @@ -126,7 +127,7 @@ namespace Lucene.Net.Codecs.SimpleText NewLine(); Write(VALUE); - Write(Convert.ToString((long) n)); + Write(((long)n).ToString(CultureInfo.InvariantCulture)); NewLine(); } else if (n is float?) @@ -135,7 +136,8 @@ namespace Lucene.Net.Codecs.SimpleText NewLine(); Write(VALUE); - Write(Convert.ToString((float) n)); + // LUCENENET: Need to specify the "R" for round-trip: http://stackoverflow.com/a/611564/181087 + Write(((float)n).ToString("R", CultureInfo.InvariantCulture)); NewLine(); } else if (n is double?) @@ -144,7 +146,8 @@ namespace Lucene.Net.Codecs.SimpleText NewLine(); Write(VALUE); - Write(Convert.ToString((double) n)); + // LUCENENET: Need to specify the "R" for round-trip: http://stackoverflow.com/a/611564/181087 + Write(((double)n).ToString("R", CultureInfo.InvariantCulture)); NewLine(); } else http://git-wip-us.apache.org/repos/asf/lucenenet/blob/f5cebafd/src/Lucene.Net.TestFramework/Index/BaseStoredFieldsFormatTestCase.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.TestFramework/Index/BaseStoredFieldsFormatTestCase.cs b/src/Lucene.Net.TestFramework/Index/BaseStoredFieldsFormatTestCase.cs index 0b11f29..a63eb84 100644 --- a/src/Lucene.Net.TestFramework/Index/BaseStoredFieldsFormatTestCase.cs +++ b/src/Lucene.Net.TestFramework/Index/BaseStoredFieldsFormatTestCase.cs @@ -179,7 +179,7 @@ namespace Lucene.Net.Index Document docExp = docs[testID]; for (int i = 0; i < fieldCount; i++) { - Assert.AreEqual("doc " + testID + ", field f" + fieldCount + " is wrong", docExp.Get("f" + i), doc.Get("f" + i)); + assertEquals("doc " + testID + ", field f" + fieldCount + " is wrong", docExp.Get("f" + i), doc.Get("f" + i)); } } r.Dispose();