| 135 | Span<char> emptyOutput; |
| 136 | Result empty = compressor.process(source, emptyOutput); |
| 137 | SC_TEST_EXPECT(not empty); |
| 138 | SC_TEST_EXPECT(empty.errorValue() == static_cast<uint32_t>(AsyncStreamsError::CompressionOutputBufferEmpty)); |
| 139 | |
| 140 | ZLibStream inflater; |
| 141 | SC_TEST_EXPECT(inflater.init(ZLibStream::DecompressZLib)); |
| 142 | const char invalidData[4] = {0, 0, 0, 0}; |
| 143 | Span<const char> invalidInput(invalidData); |
| 144 | char outputBytes[32]; |
| 145 | Span<char> output(outputBytes); |
| 146 | Result invalid = inflater.process(invalidInput, output); |
| 147 | SC_TEST_EXPECT(not invalid); |
| 148 | SC_TEST_EXPECT(invalid.category() == AsyncStreamsResultCategory); |
| 149 | SC_TEST_EXPECT(invalid.errorValue() == static_cast<uint32_t>(AsyncStreamsError::CompressionDataInvalid)); |
| 150 | |
| 151 | char message[80]; |
| 152 | SC_TEST_EXPECT(formatAsyncStreamsError(invalid, message).status == ResultErrorFormatStatus::Success); |
| 153 | |
| 154 | ZLibStream invalidAlgorithm; |
| 155 | Result unsupported = invalidAlgorithm.init(static_cast<ZLibStream::Algorithm>(-1)); |
| 156 | SC_TEST_EXPECT(not unsupported); |
| 157 | SC_TEST_EXPECT(unsupported.errorValue() == static_cast<uint32_t>(AsyncStreamsError::CompressionStreamInvalid)); |
| 158 | } |
| 159 | |
| 160 | void SC::ZLibStreamTest::uninitializedStream() |
| 161 | { |
| 162 | ZLibStream stream; |
| 163 | char inputByte[1] = {'x'}; |
| 164 | char outputBytes[16]; |
| 165 | Span<const char> input(inputByte); |
| 166 | Span<char> output(outputBytes); |
| 167 | Result process = stream.process(input, output); |
| 168 | SC_TEST_EXPECT(not process); |
| 169 | SC_TEST_EXPECT(process.category() == AsyncStreamsResultCategory); |
| 170 | SC_TEST_EXPECT(process.errorValue() == static_cast<uint32_t>(AsyncStreamsError::CompressionNotInitialized)); |
| 171 | |
| 172 | bool ended = false; |
| 173 | Result finalize = stream.finalize(output, ended); |
| 174 | SC_TEST_EXPECT(not finalize); |
| 175 | SC_TEST_EXPECT(finalize.category() == AsyncStreamsResultCategory); |
| 176 | SC_TEST_EXPECT(finalize.errorValue() == static_cast<uint32_t>(AsyncStreamsError::CompressionNotInitialized)); |
| 177 | } |
| 178 | |
| 179 | void SC::ZLibStreamTest::syncCompression(ZLibStream::Algorithm compressionAlgorithm, const StringView inputString, |
nothing calls this directly
no test coverage detected