namespace HumanReadableParser {
+namespace {
std::unordered_set<std::string> yeses = {
"y", "1", "yes", "true", "on", "yeah", "yep", "of course", "sure thing"
};
+} // namespace
bool isYes(const std::string &value) {
std::string lower_value(value);
#include <creds-sd-bus-inner.h>
+namespace {
int copyStr(char **destStr, const std::string &str) {
if (!destStr) {
return CYNARA_API_INVALID_PARAM;
*destStr = destTmp;
return CYNARA_API_SUCCESS;
}
+} // namespace
int getPid(sd_bus *bus, const char *name, pid_t *pid) {
return Cynara::tryCatch([&bus, &name, &pid]() {
#include "CmdlineParser.h"
#include "Cynara.h"
+namespace {
void daemonize(void) {
switch (fork()) {
case -1:
close(fd);
}
}
+} // namespace
int main(int argc, char **argv) {
try {
#include <dpl/binary_queue.h>
RUNNER_TEST_GROUP_INIT(DPL)
+namespace {
inline std::string BinaryQueueToString(const DPL::BinaryQueue &queue)
{
char *buffer = new char[queue.Size()];
delete[] buffer;
return result;
}
+} // namespace
/*
Name: BinaryQueue_InitialEmpty
RUNNER_ASSERT(BinaryQueueToString(copy) == "abcdef");
}
+namespace {
class Visitor :
public DPL::BinaryQueue::BucketVisitor
{
++m_index;
}
};
+} // namespace
/*
Name: BinaryQueue_Visitor
return errnosStrings;
}
-} // namespace anonymous
-
-using namespace Cynara;
-
struct Status {
bool success = false;
std::string errorMsg;
};
+} // namespace anonymous
+
+using namespace Cynara;
+
TEST(SafeStrError, knownErrnosPositive)
{
const std::vector<std::string> KNOWN_ERRNOS_STRINGS =
const std::string SOME_LINE = "some line";
const std::string SOME_FILE = "some.file";
-} // namespace anonymous
-
class DerivedException : public Cynara::Exception {
public:
DerivedException() {}
};
};
+} // namespace anonymous
+
TEST(TryCatch, forcedUnwindNegative)
{
pthread_t id;
#include <common/protocol/ProtocolSerialization.h>
#include <cynara-limits.h>
+namespace {
class FakeIStream : public Cynara::IStream {
public:
MOCK_METHOD2(read, void(size_t, void*));
memcpy(arg1, &hparam, sizeof(hparam));
}
ACTION_P(AssignString, param) { strcpy(static_cast<char*>(arg1), param); }
+} // namespace
TEST(Serialization, maxStringPositive) {
using ::testing::_;
using namespace Cynara;
+namespace {
class PolicyBucketFixture : public ::testing::Test {
public:
virtual ~PolicyBucketFixture() {}
"badid\n", " badid", "bad id", "badid "
};
};
+} // namespace
TEST_F(PolicyBucketFixture, FilteredPositive) {
using ::testing::UnorderedElementsAre;
/*** Test for getKeyAndValue() ***/
+namespace {
struct getKeyAndValueTestEntry {
std::string testString;
std::string key;
std::string value;
};
+} // namespace
TEST(Parser, getKeyAndValuePositive) {
const std::vector<struct getKeyAndValueTestEntry> getKeyAndValueTestEntries = {
using namespace Cynara;
+namespace {
class PolicyKeyGenerator {
public:
typedef std::vector<std::string> Features;
Features m_users;
Features m_privileges;
};
+} // namespace
TEST(Performance, bucketFiltered100000Positive) {
using std::chrono::microseconds;
using namespace Cynara;
+namespace {
MATCHER_P(PolicyAtPtrEq, policy, "") {
return std::tie(policy->key(), policy->result())
== std::tie(arg->key(), arg->result());
}
}
};
+} // namespace
TEST_F(BucketDeserializerFixture, loadEmptyPositive) {
using ::testing::IsEmpty;
#include <storage/StorageDeserializer.h>
#include <types/PolicyBucket.h>
+namespace {
MATCHER_P(PolicyBucketIdPolicyEq, expected, "") {
auto bucket1 = expected.second;
auto bucket2 = arg.second;
return emptyBucketStream();
};
};
+} // namespace
using namespace Cynara;
using namespace Cynara;
+namespace {
// TODO: Move to helpers or other .h
MATCHER_P(PolicyAtPtrEq, policy, "") {
return std::tie(policy->key(), policy->result())
== std::tie(arg->key(), arg->result());
}
+} // namespace
// Test if dumping and loading yields the same result
TEST(DumpLoad, BucketPositive) {
#include <storage/StorageSerializer.h>
#include <types/PolicyBucketId.h>
+namespace {
class FakeStreamForBucketId {
public:
typedef std::shared_ptr<Cynara::StorageSerializer<std::stringstream> >
Cynara::Buckets buckets;
FakeStreamForBucketId fakeStreamOpener;
};
+} // namespace
using namespace Cynara;
#include "TestEventListenerProxy.h"
+namespace {
class PropertyAwarePrettyUnitTestResultPrinter : public Cynara::TestEventListenerProxy {
using Cynara::TestEventListenerProxy::TestEventListenerProxy;
originalListener()->OnTestEnd(testInfo);
}
};
+} // namespace
int main(int argc, char** argv) {
// Disables elapsed time by default.