mirror of
https://github.com/MaskRay/ccls.git
synced 2025-01-19 12:05:50 +00:00
Usage initializer_list
This commit is contained in:
parent
a1423a39a0
commit
8debcf1d9d
@ -71,6 +71,9 @@ struct TestIndexer : IIndexer {
|
||||
|
||||
} // namespace
|
||||
|
||||
IIndexer::TestEntry::TestEntry(const std::string& path, int num_indexes)
|
||||
: path(path), num_indexes(num_indexes) {}
|
||||
|
||||
// static
|
||||
std::unique_ptr<IIndexer> IIndexer::MakeClangIndexer() {
|
||||
return MakeUnique<ClangIndexer>();
|
||||
@ -78,6 +81,6 @@ std::unique_ptr<IIndexer> IIndexer::MakeClangIndexer() {
|
||||
|
||||
// static
|
||||
std::unique_ptr<IIndexer> IIndexer::MakeTestIndexer(
|
||||
const std::vector<TestEntry>& entries) {
|
||||
std::initializer_list<TestEntry> entries) {
|
||||
return TestIndexer::FromEntries(entries);
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <initializer_list>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@ -22,11 +23,13 @@ struct IIndexer {
|
||||
struct TestEntry {
|
||||
std::string path;
|
||||
int num_indexes = 0;
|
||||
|
||||
TestEntry(const std::string& path, int num_indexes);
|
||||
};
|
||||
|
||||
static std::unique_ptr<IIndexer> MakeClangIndexer();
|
||||
static std::unique_ptr<IIndexer> MakeTestIndexer(
|
||||
const std::vector<TestEntry>& entries);
|
||||
std::initializer_list<TestEntry> entries);
|
||||
|
||||
virtual ~IIndexer() = default;
|
||||
virtual std::vector<std::unique_ptr<IndexFile>> Index(
|
||||
|
@ -627,7 +627,7 @@ TEST_SUITE("ImportPipeline") {
|
||||
};
|
||||
|
||||
TEST_CASE_FIXTURE(Fixture, "index request with zero results") {
|
||||
indexer = IIndexer::MakeTestIndexer({{"foo.cc", 0}});
|
||||
indexer = IIndexer::MakeTestIndexer({IIndexer::TestEntry{"foo.cc", 0}});
|
||||
|
||||
MakeRequest("foo.cc");
|
||||
|
||||
@ -639,7 +639,7 @@ TEST_SUITE("ImportPipeline") {
|
||||
}
|
||||
|
||||
TEST_CASE_FIXTURE(Fixture, "one index request") {
|
||||
indexer = IIndexer::MakeTestIndexer({{"foo.cc", 100}});
|
||||
indexer = IIndexer::MakeTestIndexer({IIndexer::TestEntry{"foo.cc", 100}});
|
||||
|
||||
MakeRequest("foo.cc");
|
||||
|
||||
@ -651,7 +651,8 @@ TEST_SUITE("ImportPipeline") {
|
||||
}
|
||||
|
||||
TEST_CASE_FIXTURE(Fixture, "multiple index requests") {
|
||||
indexer = IIndexer::MakeTestIndexer({{"foo.cc", 100}, {"bar.cc", 5}});
|
||||
indexer = IIndexer::MakeTestIndexer(
|
||||
{IIndexer::TestEntry{"foo.cc", 100}, IIndexer::TestEntry{"bar.cc", 5}});
|
||||
|
||||
MakeRequest("foo.cc");
|
||||
MakeRequest("bar.cc");
|
||||
|
Loading…
Reference in New Issue
Block a user