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 support for empty BLOB/CLOB #707

Closed
jgebal opened this Issue Jul 10, 2018 · 0 comments

Comments

Projects
None yet
1 participant
@jgebal
Copy link
Member

jgebal commented Jul 10, 2018

Currently BLOB/CLOB when empty (initialized but not assigned a value) behaves like this:

create or replace package test_empty_blob_clob is
  --%suite(Empty BLOB/CLOB behavior)

  --%test(Empty BLOB fails on is_null)
  procedure empty_blob_is_null;

  --%test(Empty CLOB fails on is_null)
  procedure empty_clob_is_null;

  --%test(Empty BLOB succeeds on is_not_null)
  procedure empty_blob_is_not_null;

  --%test(Empty CLOB succeeds on is_not_null)
  procedure empty_clob_is_not_null;

  --%test(Empty BLOB fails on is_empty)
  procedure empty_blob_is_empty;

  --%test(Empty CLOB fails is_empty)
  procedure empty_clob_is_empty;

  --%test(Empty BLOB succeeds on empty BLOB comparison)
  procedure empty_blob_equals_empty;

  --%test(Empty CLOB succeeds on empty CLOB comparison)
  procedure empty_clob_equals_empty;
  
end;
/
create or replace package body test_empty_blob_clob is

  procedure empty_blob_is_null is
    l_lob blob := empty_blob();
  begin
    ut.expect(l_lob).to_be_null;
  end;

  procedure empty_clob_is_null is
    l_lob clob := empty_clob();
  begin
    ut.expect(l_lob).to_be_null;
  end;

  procedure empty_blob_is_not_null is
    l_lob blob := empty_blob();
  begin
    ut.expect(l_lob).to_be_not_null;
  end;

  procedure empty_clob_is_not_null is
    l_lob clob := empty_clob();
  begin
    ut.expect(l_lob).to_be_not_null;
  end;

  procedure empty_blob_is_empty is
    l_lob blob := empty_blob();
  begin
    ut.expect(l_lob).to_(be_empty);
  end;

  procedure empty_clob_is_empty is
    l_lob clob := empty_clob();
  begin
    ut.expect(l_lob).to_(be_empty);
  end;

  procedure empty_blob_equals_empty is
    l_lob blob := empty_blob();
  begin
    ut.expect(l_lob).to_equal(empty_blob());
  end;


  procedure empty_clob_equals_empty is
    l_lob clob := empty_clob();
  begin
    ut.expect(l_lob).to_equal(empty_clob());
  end;
  
end;
/

Outcomes:

Empty BLOB/CLOB behavior
  Empty BLOB fails on is_null [.107 sec] (FAILED - 1)
  Empty CLOB fails on is_null [.007 sec] (FAILED - 2)
  Empty BLOB succeeds on is_not_null [.006 sec]
  Empty CLOB succeeds on is_not_null [.003 sec]
  Empty BLOB fails on is_empty [.01 sec] (FAILED - 3)
  Empty CLOB fails is_empty [.004 sec] (FAILED - 4)
  Empty BLOB succeeds on empty BLOB comparison [.009 sec]
  Empty CLOB succeeds on empty CLOB comparison [.003 sec]
 
Failures:
 
  1) empty_blob_is_null
      Actual: NULL (blob) was expected to be null
      at "UT3.TEST_EMPTY_BLOB_CLOB.EMPTY_BLOB_IS_NULL", line 6 ut.expect(l_lob).to_be_null;
      
       
  2) empty_clob_is_null
      Actual: NULL (clob) was expected to be null
      at "UT3.TEST_EMPTY_BLOB_CLOB.EMPTY_CLOB_IS_NULL", line 12 ut.expect(l_lob).to_be_null;
      
       
  3) empty_blob_is_empty
      The matcher 'be empty' cannot be used with data type (blob).
      at "UT3.TEST_EMPTY_BLOB_CLOB.EMPTY_BLOB_IS_EMPTY", line 30 ut.expect(l_lob).to_(be_empty);
      
       
  4) empty_clob_is_empty
      The matcher 'be empty' cannot be used with data type (clob).
      at "UT3.TEST_EMPTY_BLOB_CLOB.EMPTY_CLOB_IS_EMPTY", line 36 ut.expect(l_lob).to_(be_empty);
      
       
Finished in .163359 seconds
8 tests, 4 failed, 0 errored, 0 disabled, 0 warning(s)

I would expect the tests to pass:

  Empty BLOB fails on is_empty [.01 sec] (FAILED - 3)
  Empty CLOB fails is_empty [.004 sec] (FAILED - 4)

I would also expect the expectation failure message to say:

      Actual: EMPTY (blob) was expected to be null

Rather than:

      Actual: NULL (blob) was expected to be null

@jgebal jgebal added the enhancement label Jul 10, 2018

jgebal added a commit that referenced this issue Jul 11, 2018

Added support for BLOB/CLOB in `ut_be_empty`
Resolves #707
Cleaned-up code.
Moved some tests to improve the way tests are organized.
Removed redundant tests.

@jgebal jgebal closed this in #709 Jul 11, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.