コード例 #1
0
ファイル: checker.hpp プロジェクト: tryge/libelektra
	void check(kdb::KeySet &ks) override
	{
		config.rewind();

		kdb::Key confRoot = config.next();
		if (!confRoot) throw "StructChecker: No confRoot found";

		kdb::Key cur;
		kdb::Key root = ks.next();
		if (!root) throw "StructChecker: No root key found";


		while ((cur = ks.next()))
		{
			kdb::Key searchKey = config.next();
			if (!searchKey) throw "StructChecker: More keys found than structure should have";
			if (!cur.isDirectBelow(root)) throw "StructChecker: key is not direct below";

			if (searchKey.getBaseName() != cur.getBaseName())
				throw "StructChecker: did not find expected subkey";

			cur.copyAllMeta (searchKey);
		}

		if (config.next()) throw "StructChecker: There should be more elements in the structure";
	}
コード例 #2
0
//! [ksDeepCopy]
kdb::KeySet ksDeepCopy (kdb::KeySet orig)
{
	kdb::KeySet deepCopy;
	orig.rewind ();
	while (orig.next ())
	{
		deepCopy.append (orig.current ().dup ());
	}
	return deepCopy;
}
コード例 #3
0
ファイル: factory.hpp プロジェクト: tryge/libelektra
	Factory(kdb::KeySet config) :
		m_factory()
	{
		config.rewind();
		kdb::Key root = config.next();

		m_factory.insert(std::make_pair("list", new Cnstancer<ListChecker>()));

		kdb::Key k;
		while ((k = config.next()))
		{
			if (!k.isDirectBelow(root)) throw "Factory: key for configuration is not direct below";

			kdb::KeySet cks(config.cut(k));
			m_factory.insert(std::make_pair(k.getBaseName(), new StructInstancer(cks)));
		}
	}
コード例 #4
0
/**
 * @brief Easily allows to generate regression tests for keysets.
 *
 * @param tocheck the keyset to check (name + string)
 * @param name the name of the keyset
 */
void outputGTest(kdb::KeySet tocheck, std::string name)
{
	std::cout << name << ".rewind();" << std::endl;
	tocheck.rewind();
	while(tocheck.next())
	{
		std::cout << name << ".next();" << std::endl;
		std::cout << "EXPECT_TRUE(" << name
			<< ".current().getName() == \""
			<< tocheck.current().getName()
			<< "\") << \"name of element in keyset wrong\";"
			<< std::endl;
		std::cout << "EXPECT_TRUE(" << name
			<< ".current().getString() == \""
			<< tocheck.current().getString()
			<< "\") << \"string of element in keyset wrong\";"
			<< std::endl;
	}
}