formatted_raw_ostream_test.cpp 846 B

123456789101112131415161718192021222324252627282930313233
  1. //===- llvm/unittest/Support/formatted_raw_ostream_test.cpp ---------------===//
  2. //
  3. // The LLVM Compiler Infrastructure
  4. //
  5. // This file is distributed under the University of Illinois Open Source
  6. // License. See LICENSE.TXT for details.
  7. //
  8. //===----------------------------------------------------------------------===//
  9. #include "llvm/Support/FormattedStream.h"
  10. #include "llvm/ADT/SmallString.h"
  11. #include "llvm/Support/raw_ostream.h"
  12. #include "gtest/gtest.h"
  13. using namespace llvm;
  14. namespace {
  15. TEST(formatted_raw_ostreamTest, Test_Tell) {
  16. // Check offset when underlying stream has buffer contents.
  17. SmallString<128> A;
  18. raw_svector_ostream B(A);
  19. formatted_raw_ostream C(B);
  20. char tmp[100] = "";
  21. for (unsigned i = 0; i != 3; ++i) {
  22. C.write(tmp, 100);
  23. EXPECT_EQ(100*(i+1), (unsigned) C.tell());
  24. }
  25. }
  26. }