@Test
  public void comparingComparableValuesForWhichTheCompareMethodThrowsClassCastExceptionShouldReturnBooleanWhenTheComparisonOperatorIsSupported()
      throws TypeMismatchException {
    ComparableObject comparableValue = mock(ComparableObject.class);
    when(comparableValue.compareTo(any())).thenThrow(new ClassCastException(""));

    assertThat(
        TypeUtils.compare(comparableValue, mock(Comparable.class), OQLLexerTokenTypes.TOK_NE))
            .isEqualTo(Boolean.TRUE);
    assertThat(
        TypeUtils.compare(comparableValue, mock(Comparable.class), OQLLexerTokenTypes.TOK_EQ))
            .isEqualTo(Boolean.FALSE);

    OQLLexerTokenTypes tempInstance = new OQLLexerTokenTypes() {};
    Field[] fields = OQLLexerTokenTypes.class.getDeclaredFields();

    Arrays.stream(fields).forEach(field -> {
      try {
        int token = field.getInt(tempInstance);
        if (!equalityOperators.contains(token)) {
          assertThatThrownBy(
              () -> TypeUtils.compare(comparableValue, mock(Comparable.class), token))
                  .isInstanceOf(TypeMismatchException.class).hasMessageMatching(
                      "^Unable to compare object of type ' (.*) ' with object of type ' (.*) '$");
        }
      } catch (Exception exception) {
        throw new RuntimeException(exception);
      }
    });
  }
Can't test every possible combination so try the known, relevant ones.
geode-core/src/test/java/org/apache/geode/cache/query/internal/types/TypeUtilsJUnitTest.java