File: TestTemplateString.cxx

package info (click to toggle)
mpd 0.24.6-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 10,736 kB
  • sloc: cpp: 75,014; python: 1,408; xml: 628; perl: 469; java: 289; sh: 286; ansic: 235; makefile: 105
file content (35 lines) | stat: -rw-r--r-- 875 bytes parent folder | download | duplicates (3)
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
// SPDX-License-Identifier: BSD-2-Clause
// author: Max Kellermann <max.kellermann@gmail.com>

#include "util/TemplateString.hxx"

#include <gtest/gtest.h>

TEST(TemplateString, FromChar)
{
	using namespace TemplateString;
	static constexpr auto result = FromChar('?');
	static_assert(result.size == 1);
	ASSERT_STREQ(result, "?");
}

TEST(TemplateString, FromLiteral)
{
	using namespace TemplateString;
	static constexpr auto result = FromLiteral("foobar");
	static_assert(result.size == 6);
	ASSERT_STREQ(result, "foobar");
}

TEST(TemplateString, Concat)
{
	using namespace TemplateString;
	static constexpr auto foo = Concat('f', 'o', 'o');
	static_assert(foo.size == 3);
	ASSERT_STREQ(foo, "foo");

	static constexpr auto bar = Concat('b', 'a', 'r');
	static constexpr auto foobar = Concat(foo, bar);
	static_assert(foobar.size == 6);
	ASSERT_STREQ(foobar, "foobar");
}