-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathRope.join.test.cpp
More file actions
45 lines (39 loc) · 1.49 KB
/
Rope.join.test.cpp
File metadata and controls
45 lines (39 loc) · 1.49 KB
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
45
#include "Rope.Decimal.h"
#include "Rope.StringView.h"
#include "Rope.char.h"
#include "Rope.join.h"
#include "Rope.store.h"
#include "StringStore.literal.h"
#include "StringView.equals.h"
#include "StringView.literal.h"
#include "StringView.store.h"
#include <gtest/gtest.h>
using namespace string19;
TEST(Rope, joinEmpty) {
constexpr auto rope = Separator{','}.join();
constexpr auto N = ropeCount(rope);
constexpr auto store = ropeStore<N>(rope);
static_assert(viewStore(store) == viewLiteral(""));
EXPECT_EQ(store, storeLiteral(""));
}
TEST(Rope, joinChar) {
constexpr auto rope = Separator{','}.join('1', '2', '3');
constexpr auto N = ropeCount(rope);
constexpr auto store = ropeStore<N>(rope);
static_assert(viewStore(store) == viewLiteral("1,2,3"));
EXPECT_EQ(store, storeLiteral("1,2,3"));
}
TEST(Rope, joinView) {
constexpr auto rope = Separator{viewLiteral(", ")}.join(viewLiteral("1"), '2', '3');
constexpr auto N = ropeCount(rope);
constexpr auto store = ropeStore<N>(rope);
static_assert(viewStore(store) == viewLiteral("1, 2, 3"));
EXPECT_EQ(store, storeLiteral("1, 2, 3"));
}
TEST(Rope, joinDecimal) {
constexpr auto rope = Separator{viewLiteral(", ")}.join(decimal<1>, decimal<-2>, decimal<3>);
constexpr auto N = ropeCount(rope);
constexpr auto store = ropeStore<N>(rope);
static_assert(viewStore(store) == viewLiteral("1, -2, 3"));
EXPECT_EQ(store, storeLiteral("1, -2, 3"));
}