]> git.proxmox.com Git - ceph.git/blame - ceph/src/arrow/cpp/src/arrow/util/queue_test.cc
import quincy 17.2.0
[ceph.git] / ceph / src / arrow / cpp / src / arrow / util / queue_test.cc
CommitLineData
1d09f67e
TL
1// Licensed to the Apache Software Foundation (ASF) under one
2// or more contributor license agreements. See the NOTICE file
3// distributed with this work for additional information
4// regarding copyright ownership. The ASF licenses this file
5// to you under the Apache License, Version 2.0 (the
6// "License"); you may not use this file except in compliance
7// with the License. You may obtain a copy of the License at
8//
9// http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing,
12// software distributed under the License is distributed on an
13// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14// KIND, either express or implied. See the License for the
15// specific language governing permissions and limitations
16// under the License.
17
18#include <gtest/gtest.h>
19
20#include "arrow/testing/gtest_util.h"
21#include "arrow/util/queue.h"
22
23namespace arrow {
24namespace util {
25
26TEST(TestSpscQueue, TestMoveOnly) {
27 SpscQueue<MoveOnlyDataType> queue(3);
28 ASSERT_TRUE(queue.IsEmpty());
29 ASSERT_FALSE(queue.IsFull());
30 ASSERT_EQ(queue.SizeGuess(), 0);
31
32 MoveOnlyDataType in(42);
33 queue.Write(std::move(in));
34 ASSERT_FALSE(queue.IsEmpty());
35 ASSERT_FALSE(queue.IsFull());
36 ASSERT_EQ(queue.SizeGuess(), 1);
37
38 queue.Write(43);
39 ASSERT_FALSE(queue.IsEmpty());
40 ASSERT_TRUE(queue.IsFull());
41 ASSERT_EQ(queue.SizeGuess(), 2);
42
43 MoveOnlyDataType out = std::move(*queue.FrontPtr());
44 ASSERT_EQ(42, *out.data);
45 queue.PopFront();
46 ASSERT_TRUE(queue.Read(out));
47 ASSERT_EQ(43, *out.data);
48
49 ASSERT_TRUE(queue.IsEmpty());
50 ASSERT_FALSE(queue.IsFull());
51 ASSERT_EQ(queue.SizeGuess(), 0);
52}
53
54} // namespace util
55} // namespace arrow