// Copyright 2015 The Weave Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "src/streams.h" #include #include #include #include #include namespace weave { TEST(Stream, CopyStreams) { provider::test::FakeTaskRunner task_runner; std::vector test_data(1024 * 1024); for (size_t i = 0; i < test_data.size(); ++i) test_data[i] = static_cast(std::hash()(i)); MemoryStream source{test_data, &task_runner}; MemoryStream destination{{}, &task_runner}; bool done = false; auto callback = base::Bind( [&test_data, &done, &destination](size_t size, ErrorPtr error) { EXPECT_FALSE(error); done = true; EXPECT_EQ(test_data, destination.GetData()); }); StreamCopier copier{&source, &destination}; copier.Copy(callback); task_runner.Run(test_data.size()); EXPECT_TRUE(done); } } // namespace weave