Exemplo n.º 1
0
bool TextureNode::sEqual(const RepoNode &other) const
{
	if (other.getTypeAsEnum() != NodeType::TEXTURE || other.getParentIDs().size() != getParentIDs().size())
	{
		return false;
	}

	TextureNode otherText = TextureNode(other);
	bool equal;

	if (equal = getFileExtension() == otherText.getFileExtension())
	{
		std::vector<char> *raw, *raw2;

		raw = getRawData();
		raw2 = otherText.getRawData();

		if (equal = (raw && raw2 && (raw->size() == raw2->size())) )
		{
			equal = !memcmp(raw->data(), raw2->data(), raw->size() * sizeof(*raw->data()));

			delete raw;
			delete raw2;
		}

	}

	return equal;
}
Exemplo n.º 2
0
TEST(RepoBSONFactoryTest, MakeTextureNodeTest)
{
	std::string ext = "jpg";
	std::string name = "textureNode." + ext;
	std::string data = "The value of this texture is represented by this string as all it takes is a char*";
	int width = 100, height = 110;

	TextureNode tex = RepoBSONFactory::makeTextureNode(name, data.c_str(), data.size(), width, height);

	ASSERT_FALSE(tex.isEmpty());

	EXPECT_EQ(name, tex.getName());
	EXPECT_EQ(width, tex.getField(REPO_LABEL_WIDTH).Int());
	EXPECT_EQ(height, tex.getField(REPO_LABEL_HEIGHT).Int());
	EXPECT_EQ(ext, tex.getFileExtension());
	std::vector<char> rawOut = tex.getRawData();
	ASSERT_EQ(data.size(), rawOut.size());
	EXPECT_EQ(0, memcmp(data.c_str(), rawOut.data(), data.size()));

	//make sure the code doesn't fail over if for some reason the name does not contain the extension
	TextureNode tex2 = RepoBSONFactory::makeTextureNode("noExtensionName", data.c_str(), data.size(), width, height);
}