Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more string tests for IndexOf and utf-8 #11

Open
ericoporto opened this issue Aug 16, 2024 · 5 comments
Open

Add more string tests for IndexOf and utf-8 #11

ericoporto opened this issue Aug 16, 2024 · 5 comments

Comments

@ericoporto
Copy link
Member

IndexOf could use a few additional utf-8 tests to ensure we are correctly getting the right index when either or both the string and needle have utf-8 characters.

There are probably other utf-8 tests that would be useful to add to strings but I don't remember right now any other cases.

@ivan-mogilko
Copy link
Contributor

ivan-mogilko commented Aug 16, 2024

Utf-8 specifics are affecting any method that:

  • manipulates individual character
  • involves a character index or length of string.

for AGS 3.*:

  • AppendChar - because it must convert unicode index to utf-8 representation
  • CompareTo - in case-insensitive case
  • EndsWith - in case-insensitive case
  • IndexOf - because it appears to be case-insensitive and uses "lowercase" for converting characters before comparison
  • LowerCase - converts characters
  • Replace - in case-insensitive case
  • ReplaceCharAt
  • StartsWith - in case-insensitive case
  • Substring
  • Truncate
  • UpperCase - converts characters
  • Chars[] property
  • Length property

for AGS 4.*:

  • IndexOf - after adding begin,end parameters
  • Trim - in case of extra unicode whitespace characters

@ericoporto
Copy link
Member Author

ericoporto commented Aug 16, 2024

ok, I added a few tests, but I also found a small bug in the new compiler.

// disabled because single utf-8 char errors the new compiler
// // UTF-8 specific test
// String utfText = "Hell";
// utfText = utfText.AppendChar('ä'); // Append a UTF-8 character
// tap.is(utfText, "Hellä", "String.AppendChar UTF-8 test");

This gives the error "test-string.asc(19): Expected a quote mark but found '¤' instead".

@ericoporto
Copy link
Member Author

I think some string UpperCase/LowerCase tests would be useful to have by just having a few strings with characters from different alphabets - like lower/upper of Greek, and so on.

@ivan-mogilko
Copy link
Contributor

ivan-mogilko commented Aug 17, 2024

This gives the error "test-string.asc(19): Expected a quote mark but found '¤' instead".

I cannot remember what happened when I tested unicode char literals. But they are supposed to work, at least with the new compiler which is more advanced.
Could you open a bug ticket in the main repository?

@ericoporto
Copy link
Member Author

Sure, I will create a proper bug report later. To be specific this is only a bug in the new compiler, it works fine in the old one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants