From 6506607c4274216d5aef08181dba043d6e39124c Mon Sep 17 00:00:00 2001 From: Matti Nielsen Date: Mon, 23 Sep 2024 09:54:31 +0200 Subject: [PATCH] cleanup everything --- .../src/EditinExcelImpl.Codeunit.al | 2 -- .../src/EditInExcelTest.Codeunit.al | 20 +++++++++---------- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/src/System Application/App/Edit in Excel/src/EditinExcelImpl.Codeunit.al b/src/System Application/App/Edit in Excel/src/EditinExcelImpl.Codeunit.al index 1bcd93fa6..847d04f82 100644 --- a/src/System Application/App/Edit in Excel/src/EditinExcelImpl.Codeunit.al +++ b/src/System Application/App/Edit in Excel/src/EditinExcelImpl.Codeunit.al @@ -232,8 +232,6 @@ codeunit 1482 "Edit in Excel Impl." if ConvertedName[CurrentPosition] in ['–'] then begin StartStr := CopyStr(ConvertedName, 1, CurrentPosition - 1); EndStr := CopyStr(ConvertedName, CurrentPosition + 1); - // TODO: Have a look at these edge cases around spaces, - // make it behave like the other code we have. ConvertedName := StrSubstNo(XmlByteEncoding3Tok, StartStr, 'x2013', EndStr); // length of _x00nn_ minus one that will be added later end else begin diff --git a/src/System Application/Test/Edit in Excel/src/EditInExcelTest.Codeunit.al b/src/System Application/Test/Edit in Excel/src/EditInExcelTest.Codeunit.al index 28ef7e7f1..d0f7f76aa 100644 --- a/src/System Application/Test/Edit in Excel/src/EditInExcelTest.Codeunit.al +++ b/src/System Application/Test/Edit in Excel/src/EditInExcelTest.Codeunit.al @@ -106,7 +106,7 @@ codeunit 132525 "Edit in Excel Test" EnDashFieldName4: Text; ForwardSlashesFieldName: Text; ManyForwardSlashesFieldName: Text; - ForwardSlashesAndUnderscoresFieldName: Text; + ForwardSlashesEmDashesAndUnderscoresFieldName: Text; begin Init(); FieldNameStartingWDigit := EditinExcelTestLibrary.ExternalizeODataObjectName('3field'); @@ -121,24 +121,22 @@ codeunit 132525 "Edit in Excel Test" // to an underscore. EnDashFieldName2 := EditinExcelTestLibrary.ExternalizeODataObjectName('lager –reklassfication field'); - // The special symbol `en dash` will be converted to _x2013_ and the space will be a converted - // to an underscore. + // The special symbol `en dash` will be converted to _x2013_. EnDashFieldName3 := EditinExcelTestLibrary.ExternalizeODataObjectName('lager–reklassfication field'); // The two forward slashes will be converted to underscores and the `en dash` will be converted to _x2013_. EnDashFieldName4 := EditinExcelTestLibrary.ExternalizeODataObjectName('lager/–/reklassfication field'); - // Two forward slashes will have the first replaced with an underscore and the next removed. + // Two forward slashes will have the first replaced with an underscore and the second removed. ForwardSlashesFieldName := EditinExcelTestLibrary.ExternalizeODataObjectName('lager//reklassfication field'); - // When we have a lot of forward slashes it only replaces the first one with an underscore and the rest - // are truncated. + // When we have a lot of forward slashes it only replaces the first one with an underscore and the rest are truncated. ManyForwardSlashesFieldName := EditinExcelTestLibrary.ExternalizeODataObjectName('lager////////reklassfication field'); - // The first forward slash will be converted to an underscore, the next underscore does not hit any - // special case so just stays as an underscore, the next forward slash follows the rule of not allowing - // two underscores when converting from a special symbol to underscore. - ForwardSlashesAndUnderscoresFieldName := EditinExcelTestLibrary.ExternalizeODataObjectName('lager/_/-reklassfication field'); + // The first forward slash will be converted to an underscore, the next underscore does not hit any special case so just + // stays as an underscore, the next forward slash is removed because it follows the rule of not allowing two underscores + // when converting from a special symbol to underscore(unless that special character is translated to a byte value). + ForwardSlashesEmDashesAndUnderscoresFieldName := EditinExcelTestLibrary.ExternalizeODataObjectName('lager/_/-reklassfication field'); LibraryAssert.AreEqual('field', RegularFieldName, 'Conversion alters name that does not begin with a string'); LibraryAssert.AreEqual('_x0033_field', FieldNameStartingWDigit, 'Did not convert the name with number correctly'); @@ -150,7 +148,7 @@ codeunit 132525 "Edit in Excel Test" LibraryAssert.AreEqual('lager__x2013__reklassfication_field', EnDashFieldName4, 'Did not convert the name with forward slashes around `en dash` correctly'); LibraryAssert.AreEqual('lager_reklassfication_field', ForwardSlashesFieldName, 'Did not convert the name with 2 forward slashes correctly'); LibraryAssert.AreEqual('lager_reklassfication_field', ManyForwardSlashesFieldName, 'Did not convert the name with many forward slashes correctly'); - LibraryAssert.AreEqual('lager__reklassfication_field', ForwardSlashesAndUnderscoresFieldName, 'Did not convert the name with '); + LibraryAssert.AreEqual('lager__reklassfication_field', ForwardSlashesEmDashesAndUnderscoresFieldName, 'Did not convert the name with forward slashes, em dash and underscores correctly'); end; [Test]