bool test_bufferedwriter_basic() { WriteTestSource testSource; BufferedWriter writer; writer.init(&testSource, 10); HttpError err = writer.write("1234567890", 10); if (err != HttpError::Ok) { testf("Write inicated failure"); return false; } if (testSource.dataWritten.size() != 0) { testf("Data written to destination despite buffering"); return false; } err = writer.write("a", 1); if (err != HttpError::Ok) { testf("Write inicated failure"); return false; } if (testSource.dataWritten.size() != 11) { testf("Wrote %u bytes to destination instead of expected %u", testSource.dataWritten.size(), 11); return false; } if (std::memcmp(&testSource.dataWritten[0], "1234567890a", 11) != 0) { testf("Did not write expected data"); return false; } return true; }
virtual void to_line(CCVertex& v, BufferedWriter& fout) { sprintf(buf, "%d\t%d\n", v.id, v.value); fout.write(buf); }