Bug 1275198 - Part 2: Simple test cases. r=francois.

This commit is contained in:
Henry Chang 2016-05-30 05:29:00 +02:00
parent 074726d052
commit c8e28547cf
2 changed files with 25 additions and 0 deletions

View File

@ -0,0 +1,24 @@
#include "safebrowsing.pb.h"
#include "gtest/gtest.h"
TEST(SafeBrowsingProtobuf, Empty)
{
using namespace mozilla::safebrowsing;
const std::string CLIENT_ID = "firefox";
// Construct a simple update request.
FetchThreatListUpdatesRequest r;
r.set_allocated_client(new ClientInfo());
r.mutable_client()->set_client_id(CLIENT_ID);
// Then serialize.
std::string s;
r.SerializeToString(&s);
// De-serialize.
FetchThreatListUpdatesRequest r2;
r2.ParseFromString(s);
ASSERT_EQ(r2.client().client_id(), CLIENT_ID);
}

View File

@ -10,6 +10,7 @@ LOCAL_INCLUDES += [
UNIFIED_SOURCES += [
'TestChunkSet.cpp',
'TestSafeBrowsingProtobuf.cpp',
'TestUrlClassifierUtils.cpp',
]