-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathraw_buffer.cc
More file actions
44 lines (29 loc) · 1001 Bytes
/
raw_buffer.cc
File metadata and controls
44 lines (29 loc) · 1001 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <gtest/gtest.h>
#include <type_traits>
#include "allscale/utils/raw_buffer.h"
#include "allscale/utils/string_utils.h"
namespace allscale {
namespace utils {
TEST(RawBuffer,TypeProperties) {
EXPECT_TRUE(std::is_copy_constructible<RawBuffer>::value);
EXPECT_TRUE(std::is_move_constructible<RawBuffer>::value);
EXPECT_TRUE(std::is_copy_assignable<RawBuffer>::value);
EXPECT_TRUE(std::is_move_assignable<RawBuffer>::value);
EXPECT_TRUE(std::is_destructible<RawBuffer>::value);
}
TEST(RawBuffer,Basic) {
int data[5] = { 1, 2, 3, 4, 5 };
RawBuffer buffer(data);
// check consuming individual elements
EXPECT_EQ(1,buffer.consume<int>());
EXPECT_EQ(2,buffer.consume<int>());
// consume an array of elements
int* array = buffer.consumeArray<int>(2);
EXPECT_EQ(data[2],array[0]);
EXPECT_EQ(data[3],array[1]);
EXPECT_EQ(data+2,array);
// check final element
EXPECT_EQ(5,buffer.consume<int>());
}
} // end namespace utils
} // end namespace allscale