Skip to content

Commit

Permalink
Adjust test name, and add zero length blob reading test for text
Browse files Browse the repository at this point in the history
  • Loading branch information
nirosys committed Aug 5, 2024
1 parent 928ccf7 commit e0e9fcc
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion test/test_ion_binary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@ TEST(IonBinaryBlob, CanFullyReadBlobUsingPartialReads) {

// Simple test to ensure that if we supply a buffer size of 0 to ion_reader_read_lob_bytes, we don't assert. If the user
// is reading values via the LOB size, and does not specifically handle 0-lengthed LOBs the reader shouldn't fail.
TEST(IonBinaryBlob, CanReadZeroLengthBlobWithLobLength) {
TEST(IonBinaryBlob, CanReadZeroLength) {
hREADER reader;
ION_TYPE type;
const char *buffer = "\xE0\x01\x00\xEA\xA0";
Expand Down
19 changes: 19 additions & 0 deletions test/test_ion_text.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,25 @@ TEST(IonTextBlob, CanReadBlob) {
tid_BLOB, 23, "This is a BLOB of text.");
}

TEST(IonTextBlob, CanReadZeroLength) {
hREADER reader;
ION_TYPE type;
const char *buffer = "{{}}";
char bytes[1]; // Shouldn't write any..

SIZE lob_size, bytes_read;
ION_ASSERT_OK(ion_reader_open_buffer(&reader, (BYTE*)buffer, 4, NULL));

ION_ASSERT_OK(ion_reader_next(reader, &type));
ASSERT_EQ(tid_BLOB, type);
ION_ASSERT_OK(ion_reader_get_lob_size(reader, &lob_size));
ASSERT_EQ(0, lob_size);
ION_ASSERT_OK(ion_reader_read_lob_bytes(reader, (BYTE*)bytes, lob_size, &bytes_read));
ASSERT_EQ(0, bytes_read);

ION_ASSERT_OK(ion_reader_close(reader));
}

void test_text_list(const char *ion_text) {
ION_TYPE expected_tid = tid_LIST;

Expand Down

0 comments on commit e0e9fcc

Please sign in to comment.