view C++/Tests/Hash/main.cpp @ 263:fb91d4dc046b

Removal of Luae
author David Demelier <markand@malikania.fr>
date Tue, 14 Oct 2014 09:14:33 +0200
parents b686a09fb9c6
children ed3cc10761e4
line wrap: on
line source

/*
 * main.cpp -- test the hash cryptographic functions
 *
 * Copyright (c) 2013, 2014 David Demelier <markand@malikania.fr>
 *
 * Permission to use, copy, modify, and/or distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

#include <gtest/gtest.h>

#include <Hash.h>

/*
 * We test the "Hello World" message in all cryptographic functions.
 */

TEST(Hash, md5)
{
	std::string expected = "b10a8db164e0754105b7a99be72e3fe5";
	std::string output = Hash::md5("Hello World");

	ASSERT_EQ(expected, output);
}

TEST(Hash, sha1)
{
	std::string expected = "0a4d55a8d778e5022fab701977c5d840bbc486d0";
	std::string output = Hash::sha1("Hello World");

	ASSERT_EQ(expected, output);
}

TEST(Hash, sha256)
{
	std::string expected = "a591a6d40bf420404a011733cfb7b190d62c65bf0bcda32b57b277d9ad9f146e";
	std::string output = Hash::sha256("Hello World");

	ASSERT_EQ(expected, output);
}

TEST(Hash, sha512)
{
	std::string expected = "2c74fd17edafd80e8447b0d46741ee243b7eb74dd2149a0ab1b9246fb30382f27e853d8585719e0e67cbda0daa8f51671064615d645ae27acb15bfb1447f459b";
	std::string output = Hash::sha512("Hello World");

	ASSERT_EQ(expected, output);
}

int main(int argc, char **argv)
{
	testing::InitGoogleTest(&argc, argv);

	return RUN_ALL_TESTS();
}