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
|
} // namespace
|
||||||
|
|
||||||
|
IIndexer::TestEntry::TestEntry(const std::string& path, int num_indexes)
|
||||||
|
: path(path), num_indexes(num_indexes) {}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
std::unique_ptr<IIndexer> IIndexer::MakeClangIndexer() {
|
std::unique_ptr<IIndexer> IIndexer::MakeClangIndexer() {
|
||||||
return MakeUnique<ClangIndexer>();
|
return MakeUnique<ClangIndexer>();
|
||||||
@ -78,6 +81,6 @@ std::unique_ptr<IIndexer> IIndexer::MakeClangIndexer() {
|
|||||||
|
|
||||||
// static
|
// static
|
||||||
std::unique_ptr<IIndexer> IIndexer::MakeTestIndexer(
|
std::unique_ptr<IIndexer> IIndexer::MakeTestIndexer(
|
||||||
const std::vector<TestEntry>& entries) {
|
std::initializer_list<TestEntry> entries) {
|
||||||
return TestIndexer::FromEntries(entries);
|
return TestIndexer::FromEntries(entries);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <initializer_list>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@ -22,11 +23,13 @@ struct IIndexer {
|
|||||||
struct TestEntry {
|
struct TestEntry {
|
||||||
std::string path;
|
std::string path;
|
||||||
int num_indexes = 0;
|
int num_indexes = 0;
|
||||||
|
|
||||||
|
TestEntry(const std::string& path, int num_indexes);
|
||||||
};
|
};
|
||||||
|
|
||||||
static std::unique_ptr<IIndexer> MakeClangIndexer();
|
static std::unique_ptr<IIndexer> MakeClangIndexer();
|
||||||
static std::unique_ptr<IIndexer> MakeTestIndexer(
|
static std::unique_ptr<IIndexer> MakeTestIndexer(
|
||||||
const std::vector<TestEntry>& entries);
|
std::initializer_list<TestEntry> entries);
|
||||||
|
|
||||||
virtual ~IIndexer() = default;
|
virtual ~IIndexer() = default;
|
||||||
virtual std::vector<std::unique_ptr<IndexFile>> Index(
|
virtual std::vector<std::unique_ptr<IndexFile>> Index(
|
||||||
|
@ -627,7 +627,7 @@ TEST_SUITE("ImportPipeline") {
|
|||||||
};
|
};
|
||||||
|
|
||||||
TEST_CASE_FIXTURE(Fixture, "index request with zero results") {
|
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");
|
MakeRequest("foo.cc");
|
||||||
|
|
||||||
@ -639,7 +639,7 @@ TEST_SUITE("ImportPipeline") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE_FIXTURE(Fixture, "one index request") {
|
TEST_CASE_FIXTURE(Fixture, "one index request") {
|
||||||
indexer = IIndexer::MakeTestIndexer({{"foo.cc", 100}});
|
indexer = IIndexer::MakeTestIndexer({IIndexer::TestEntry{"foo.cc", 100}});
|
||||||
|
|
||||||
MakeRequest("foo.cc");
|
MakeRequest("foo.cc");
|
||||||
|
|
||||||
@ -651,7 +651,8 @@ TEST_SUITE("ImportPipeline") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE_FIXTURE(Fixture, "multiple index requests") {
|
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("foo.cc");
|
||||||
MakeRequest("bar.cc");
|
MakeRequest("bar.cc");
|
||||||
|
Loading…
Reference in New Issue
Block a user