// Copyright 2019 Google LLC1//2// Licensed under the Apache License, Version 2.0 (the "License");3// you may not use this file except in compliance with the License.4// You may obtain a copy of the License at5//6// https://www.apache.org/licenses/LICENSE-2.07//8// Unless required by applicable law or agreed to in writing, software9// distributed under the License is distributed on an "AS IS" BASIS,10// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.11// See the License for the specific language governing permissions and12// limitations under the License.1314#include "chan.h"1516#include "gmock/gmock.h"17#include "gtest/gtest.h"1819#include <thread>2021TEST(ChanTest, PutTakeClose) {22dap::Chan<int> chan;23auto thread = std::thread([&] {24chan.put(10);25chan.put(20);26chan.put(30);27chan.close();28});29EXPECT_EQ(chan.take(), dap::optional<int>(10));30EXPECT_EQ(chan.take(), dap::optional<int>(20));31EXPECT_EQ(chan.take(), dap::optional<int>(30));32EXPECT_EQ(chan.take(), dap::optional<int>());33thread.join();34}353637