Skip to content

Commit

Permalink
cleanup everything
Browse files Browse the repository at this point in the history
  • Loading branch information
DenLilleMand committed Sep 23, 2024
1 parent ea85047 commit 6506607
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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');
Expand All @@ -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]
Expand Down

0 comments on commit 6506607

Please sign in to comment.