add catch2 based test setup including some basic test cases
This commit is contained in:
@@ -19,9 +19,19 @@
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "sqlite/CppSQLite3.h"
|
||||
|
||||
#include "StorageEdge.h"
|
||||
#include "StorageError.h"
|
||||
#include "StorageFile.h"
|
||||
#include "StorageLocalSymbol.h"
|
||||
#include "StorageNode.h"
|
||||
#include "StorageOccurrence.h"
|
||||
#include "StorageSourceLocation.h"
|
||||
#include "StorageSymbol.h"
|
||||
|
||||
namespace sourcetrail
|
||||
{
|
||||
/**
|
||||
@@ -49,25 +59,23 @@ namespace sourcetrail
|
||||
void rollbackTransaction();
|
||||
void optimizeDatabaseMemory();
|
||||
|
||||
int addNode(const std::string& serializedNameHierarchy);
|
||||
void addSymbol(int symbolId, int definitionKind);
|
||||
void addFile(int nodeId, const std::string& filePath);
|
||||
int addEdge(int sourceId, int targetId, int edgeKind);
|
||||
int addLocalSymbol(const std::string& name);
|
||||
int addSourceLocation(
|
||||
int fileId,
|
||||
int startLineNumber,
|
||||
int startColumnNumber,
|
||||
int endLineNumber,
|
||||
int endColumnNumber,
|
||||
int locationKind);
|
||||
void addOccurrence(int elementId, int sourceLocationId);
|
||||
int addError(
|
||||
const std::string& message,
|
||||
bool fatal);
|
||||
int addNode(const StorageNodeData& storageNodeData);
|
||||
void addSymbol(const StorageSymbol& storageSymbol);
|
||||
void addFile(const StorageFile& storageFile);
|
||||
int addEdge(const StorageEdgeData& storageEdgeData);
|
||||
int addLocalSymbol(const StorageLocalSymbolData& storageLocalSymbolData);
|
||||
int addSourceLocation(const StorageSourceLocationData& storageSourceLocationData);
|
||||
void addOccurrence(const StorageOccurrence& storageOccurrence);
|
||||
int addError(const StorageErrorData& storageErrorData);
|
||||
|
||||
void setNodeType(int nodeId, int nodeKind);
|
||||
|
||||
template <typename ResultType>
|
||||
std::vector<ResultType> getAll() const
|
||||
{
|
||||
return doGetAll<ResultType>("");
|
||||
}
|
||||
|
||||
private:
|
||||
DatabaseStorage() = default;
|
||||
|
||||
@@ -77,9 +85,28 @@ namespace sourcetrail
|
||||
CppSQLite3Query executeQuery(const std::string& query) const;
|
||||
CppSQLite3Query executeQuery(CppSQLite3Statement& statement) const;
|
||||
|
||||
template <typename ResultType>
|
||||
std::vector<ResultType> doGetAll(const std::string& query) const;
|
||||
|
||||
mutable CppSQLite3DB m_database;
|
||||
};
|
||||
|
||||
template <>
|
||||
std::vector<StorageEdge> DatabaseStorage::doGetAll<StorageEdge>(const std::string& query) const;
|
||||
template <>
|
||||
std::vector<StorageNode> DatabaseStorage::doGetAll<StorageNode>(const std::string& query) const;
|
||||
template <>
|
||||
std::vector<StorageSymbol> DatabaseStorage::doGetAll<StorageSymbol>(const std::string& query) const;
|
||||
template <>
|
||||
std::vector<StorageFile> DatabaseStorage::doGetAll<StorageFile>(const std::string& query) const;
|
||||
template <>
|
||||
std::vector<StorageLocalSymbol> DatabaseStorage::doGetAll<StorageLocalSymbol>(const std::string& query) const;
|
||||
template <>
|
||||
std::vector<StorageSourceLocation> DatabaseStorage::doGetAll<StorageSourceLocation>(const std::string& query) const;
|
||||
template <>
|
||||
std::vector<StorageOccurrence> DatabaseStorage::doGetAll<StorageOccurrence>(const std::string& query) const;
|
||||
template <>
|
||||
std::vector<StorageError> DatabaseStorage::doGetAll<StorageError>(const std::string& query) const;
|
||||
}
|
||||
|
||||
#endif // SOURCETRAIL_DATABASE_STORAGE_H
|
||||
|
||||
Reference in New Issue
Block a user