Derby
  1. Derby
  2. DERBY-5971

Improve test coverage for SQLBoolean class

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 10.10.1.1
    • Fix Version/s: 10.10.1.1
    • Component/s: Test
    • Labels:
      None

      Description

      When looking at a test coverage report, I noticed that these methods in the SQLBoolean class are not tested:

      • falseTruthValue
      • trueTruthValue
      • greaterOrEquals
      • greaterThan
      • lessOrEquals
      • lessThan
      • is
      • isNot
      • readExternal
      • hashCode

      falseTruthValue() and trueTruthValue() are never called anywhere in the code and could be removed.

      is() and isNot() also have no callers. However, they implement the boolean IS operator which is part of the SQL standard, so it might make more sense to file a JIRA to add the syntax to the grammar rather than removing the methods.

      1. d5971-2a-hashCode.diff
        1 kB
        Knut Anders Hatlen
      2. d5971-1a-unused-and-binary-operators.diff
        8 kB
        Knut Anders Hatlen

        Issue Links

          Activity

          Hide
          Knut Anders Hatlen added a comment -

          Attaching d5971-1a-unused-and-binary-operators.diff which removes the unused methods falseTruthValue() and trueTruthValue(), and adds test cases for the binary operators =, <>, <, >, <=, >=, AND and OR.

          Show
          Knut Anders Hatlen added a comment - Attaching d5971-1a-unused-and-binary-operators.diff which removes the unused methods falseTruthValue() and trueTruthValue(), and adds test cases for the binary operators =, <>, <, >, <=, >=, AND and OR.
          Hide
          Knut Anders Hatlen added a comment -

          I ran the full regression test suite in case I had missed any callers of the two removed methods. All the tests passed. Committed revision 1404190.

          Show
          Knut Anders Hatlen added a comment - I ran the full regression test suite in case I had missed any callers of the two removed methods. All the tests passed. Committed revision 1404190.
          Hide
          Knut Anders Hatlen added a comment -

          Since we have coverage for readExternalFromArray(), implementing DERBY-2920 would help us get coverage for readExternal(). That issue suggests adding a default readExternalFromArray() method that calls the readExternal() method for the common case where there's no specialized logic in readExternalFromArray(). Otherwise, testing readExternal() could be done by merge-sorting a large table with boolean columns, but I'd prefer a test case that didn't have to populate a big table, if someone has other ideas.

          The hashCode() method could be tested by running SELECT DISTINCT on a boolean column with no unique index, I think.

          Show
          Knut Anders Hatlen added a comment - Since we have coverage for readExternalFromArray(), implementing DERBY-2920 would help us get coverage for readExternal(). That issue suggests adding a default readExternalFromArray() method that calls the readExternal() method for the common case where there's no specialized logic in readExternalFromArray(). Otherwise, testing readExternal() could be done by merge-sorting a large table with boolean columns, but I'd prefer a test case that didn't have to populate a big table, if someone has other ideas. The hashCode() method could be tested by running SELECT DISTINCT on a boolean column with no unique index, I think.
          Hide
          Knut Anders Hatlen added a comment -

          Attaching a patch that adds a test case which exercises the hashCode() method by performing a SELECT DISTINCT query.

          Committed revision 1406125.

          Show
          Knut Anders Hatlen added a comment - Attaching a patch that adds a test case which exercises the hashCode() method by performing a SELECT DISTINCT query. Committed revision 1406125.
          Hide
          Knut Anders Hatlen added a comment -

          Only is(), isNot() and readExternal() are not covered by the tests now. Since DERBY-5973 is logged for the first two methods, and fixing DERBY-2920 will take care of readExternal(), I'm resolving the issue.

          Show
          Knut Anders Hatlen added a comment - Only is(), isNot() and readExternal() are not covered by the tests now. Since DERBY-5973 is logged for the first two methods, and fixing DERBY-2920 will take care of readExternal(), I'm resolving the issue.

            People

            • Assignee:
              Knut Anders Hatlen
              Reporter:
              Knut Anders Hatlen
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development