Ad
  • Default User Avatar
  • Default User Avatar

    yep, I see this. You mean that C++ tests will be fixed and OK, but C# tests will remain buggy? Why so?
    The problem is the same: tests in C++ expected "" (string.Empty) and tests in C# expect "" (string.Empty). If this was fixed for C++, why cannot this be fixed for C#?

  • Default User Avatar

    But what's with C#?
    It is about strings only.
    Let's look into this case: Test Failed Expected is <System.String[3]>, actual is <System.String[0]> Values differ at index [0] Missing: < "0DTFT", "91XM2ANRPN6OK0PB", <string.Empty> >
    So, initial string is "0DTFT 91XM2ANRPN6OK0PB". Why does <string.Empty> present in the array? <string.Empty> is just "", i.e. nothing.
    So, virtually it is everywhere.
    I mean:
    "0DTFT 91XM2ANRPN6OK0PB"

    <string.Empty> + "0DTFT 91XM2ANRPN6OK0PB"

    "0DTFT 91XM2ANRPN6OK0PB" + <string.Empty>

    <string.Empty> + <string.Empty> + "0DTFT 91XM2ANRPN6OK0PB"

    "0DTFT 91XM2ANRPN6OK0PB" + <string.Empty> + <string.Empty>

    "0DTFT" + <string.Empty> + " 91XM2ANRPN6OK0PB"

    etc.

    These are totally equal expressions.
    They all equal to "0DTFT 91XM2ANRPN6OK0PB".

    That is why the question: if I pass "0DTFT 91XM2ANRPN6OK0PB", but your test will expect "0DTFT", "91XM2ANRPN6OK0PB" and <string.Empty> at some random position - how can I submit my solution when test fails on correct solution?

    Looks like it is about tests, not about C#.

    UPD: This is this issue: https://www.codewars.com/kata/57e76bc428d6fbc2d500036d/discuss/csharp#6171cd2de4e130004d59122c. The tests expected "", which is the same as string.Empty. The guy ejini战神 wrote he somehow solved it.

  • Default User Avatar

    so, what should we do?
    In case when tests expect empty string at random position we have nondeterministic (probabilistic) tests which are inapplicable for use.
    Why don't you want to create tests which will expect only non-empty strings at all array indexes?

  • Default User Avatar
  • Default User Avatar

    How about this?

    public class Solution { public static string[] StringToArray(string str) { return new string[0]; } } }

    Test Failed
    Expected is <System.String[1]>, actual is <System.String[0]>
    Values differ at index [0]
    Missing: < <string.Empty> >

    1. Test Failed
      Expected is <System.String[6]>, actual is <System.String[0]>
      Values differ at index [0]
      Missing: < "63C4PJK", <string.Empty>, "UG1"... >

    2. Test Failed
      Expected is <System.String[2]>, actual is <System.String[0]>
      Values differ at index [0]
      Missing: < <string.Empty>, "NGPIQNZ3LDFZ46GQ" >

    3. Test Failed
      Expected is <System.String[3]>, actual is <System.String[0]>
      Values differ at index [0]
      Missing: < "0DTFT", "91XM2ANRPN6OK0PB", <string.Empty> >

    etc.

    How can test wait for <string.Empty> if only non-empty strings are allowed in result array?

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution