| Index: omaha_hash_calculator_unittest.cc
|
| diff --git a/omaha_hash_calculator_unittest.cc b/omaha_hash_calculator_unittest.cc
|
| index d228f12641ddab3d3f048fa94c70fa2f5ad9453c..449cb9021e487a728c1a07a5b7e5f72992cb6743 100644
|
| --- a/omaha_hash_calculator_unittest.cc
|
| +++ b/omaha_hash_calculator_unittest.cc
|
| @@ -4,22 +4,40 @@
|
|
|
| #include <math.h>
|
| #include <unistd.h>
|
| +
|
| +#include <vector>
|
| +
|
| #include <glib.h>
|
| #include <gtest/gtest.h>
|
| +
|
| #include "update_engine/libcurl_http_fetcher.h"
|
| #include "update_engine/omaha_hash_calculator.h"
|
|
|
| +using std::vector;
|
| +
|
| namespace chromeos_update_engine {
|
|
|
| class OmahaHashCalculatorTest : public ::testing::Test { };
|
|
|
| +// Generated by running this on a linux shell:
|
| +// $ echo -n hi | openssl dgst -sha256 -binary | openssl base64
|
| +static const char kExpectedHash[] =
|
| + "j0NDRmSPa5bfid2pAcUXaxCm2Dlh3TwayItZstwyeqQ=";
|
| +static const char kExpectedRawHash[] = {
|
| + 0x8f, 0x43, 0x43, 0x46, 0x64, 0x8f, 0x6b, 0x96,
|
| + 0xdf, 0x89, 0xdd, 0xa9, 0x01, 0xc5, 0x17, 0x6b,
|
| + 0x10, 0xa6, 0xd8, 0x39, 0x61, 0xdd, 0x3c, 0x1a,
|
| + 0xc8, 0x8b, 0x59, 0xb2, 0xdc, 0x32, 0x7a, 0xa4
|
| +};
|
| +
|
| TEST(OmahaHashCalculatorTest, SimpleTest) {
|
| OmahaHashCalculator calc;
|
| calc.Update("hi", 2);
|
| calc.Finalize();
|
| - // Generated by running this on a linux shell:
|
| - // $ echo -n hi | openssl dgst -sha256 -binary | openssl base64
|
| - EXPECT_EQ("j0NDRmSPa5bfid2pAcUXaxCm2Dlh3TwayItZstwyeqQ=", calc.hash());
|
| + EXPECT_EQ(kExpectedHash, calc.hash());
|
| + vector<char> raw_hash(kExpectedRawHash,
|
| + kExpectedRawHash + arraysize(kExpectedRawHash));
|
| + EXPECT_TRUE(raw_hash == calc.raw_hash());
|
| }
|
|
|
| TEST(OmahaHashCalculatorTest, MultiUpdateTest) {
|
| @@ -27,9 +45,10 @@ TEST(OmahaHashCalculatorTest, MultiUpdateTest) {
|
| calc.Update("h", 1);
|
| calc.Update("i", 1);
|
| calc.Finalize();
|
| - // Generated by running this on a linux shell:
|
| - // $ echo -n hi | openssl dgst -sha256 -binary | openssl base64
|
| - EXPECT_EQ("j0NDRmSPa5bfid2pAcUXaxCm2Dlh3TwayItZstwyeqQ=", calc.hash());
|
| + EXPECT_EQ(kExpectedHash, calc.hash());
|
| + vector<char> raw_hash(kExpectedRawHash,
|
| + kExpectedRawHash + arraysize(kExpectedRawHash));
|
| + EXPECT_TRUE(raw_hash == calc.raw_hash());
|
| }
|
|
|
| TEST(OmahaHashCalculatorTest, BigTest) {
|
|
|