client/cpp/encoder_unittest.cc
// EncoderString with 4-byte vector and HMACSHA256 and
// EncoderString with Uint32 and HMACSHA256 should match.
EncoderString with 4-byte vector and HMACSHA256 and
EncoderString with Uint32 and HMACSHA256 should match.
EncoderString with 4 - byte vector and HMACSHA256 and EncoderString with Uint32 and HMACSHA256 should match .
TEST_F(EncoderUint32Test, StringUint32AndStringVectorMatch) {
  ASSERT_TRUE(encoder->EncodeString("foo", &bits_out));
  ASSERT_EQ(2281639167, bits_out);
  std::vector<uint8_t> expected_out(4);
  expected_out[0] = (bits_out & 0xFF000000) >> 24;
  expected_out[1] = (bits_out & 0x00FF0000) >> 16;
  expected_out[2] = (bits_out & 0x0000FF00) >> 8;
  expected_out[3] = bits_out  & 0x000000FF;
  delete irr_rand;
  delete deps;
  delete encoder;
  fclose(fp);
  fp = mock_urandom();
  irr_rand = new rappor::UnixKernelRand(fp);
  deps = new rappor::Deps(rappor::Md5, "client-secret", rappor::HmacSha256,
                          *irr_rand);
  encoder = new rappor::Encoder(encoder_id, *params, *deps);
  ASSERT_TRUE(encoder->EncodeString("foo", &bits_vector));
  ASSERT_EQ(expected_out, bits_vector);
}
TEST_F ( EncoderUint32Test , StringUint32AndStringVectorMatch ) { ASSERT_TRUE ( encoder -> EncodeString ( " " , & bits_out ) ) ; ASSERT_EQ ( 2281639167 , bits_out ) ; std :: vector < uint8_t > expected_out ( 4 ) ; expected_out [ 0 ] = ( bits_out & 0xFF000000 ) >> 24 ; expected_out [ 1 ] = ( bits_out & 0x00FF0000 ) >> 16 ; expected_out [ 2 ] = ( bits_out & 0x0000FF00 ) >> 8 ; expected_out [ 3 ] = bits_out & 0x000000FF ; delete irr_rand ; delete deps ; delete encoder ; fclose ( fp ) ; fp = mock_urandom ( ) ; irr_rand = new rappor :: UnixKernelRand ( fp ) ; deps = new rappor :: Deps ( rappor :: Md5 , " " , rappor :: HmacSha256 , * irr_rand ) ; encoder = new rappor :: Encoder ( encoder_id , * params , * deps ) ; ASSERT_TRUE ( encoder -> EncodeString ( " " , & bits_vector ) ) ; ASSERT_EQ ( expected_out , bits_vector ) ; }
EncoderString with 4-byte vector and HMACSHA256 and
EncoderString with Uint32 and HMACSHA256 should match.
EncoderString with 4 - byte vector and HMACSHA256 and EncoderString with Uint32 and HMACSHA256 should match .
// Reset the mock randomizer.