// Check incompatible mesh broadcast
TEST_F(FourIndexGFTest,MpiWrongBroadcast)
{
    int rank=alps::mpi::communicator().rank();
    
    alps::gf::matsubara_index omega; omega=4;
    alps::gf::momentum_index i; i=2;
    alps::gf::momentum_index j=alps::gf::momentum_index(3);
    alps::gf::index sigma(1);

    const int f=(rank==MASTER)?1:2;
    alps::gf::matsubara_gf gf_wrong(matsubara_mesh(f*beta,f*nfreq),
                                    alps::gf::momentum_index_mesh(5,1),
                                    alps::gf::momentum_index_mesh(5,1),
                                    alps::gf::index_mesh(nspins));
    gf_wrong.initialize();
    if (rank==MASTER) {
      gf_wrong(omega,i,j,sigma)=std::complex<double>(3,4);
    }

    gf_wrong.broadcast(alps::mpi::communicator(), MASTER);
    
    {
      std::complex<double> x=gf_wrong(omega,i,j,sigma);
        EXPECT_NEAR(3, x.real(),1.e-10);
        EXPECT_NEAR(4, x.imag(),1.e-10);
    }
}
TEST_F(TwoIndexGFTest,print)
{
  std::stringstream gf_stream;
  gf_stream<<gf;

  std::stringstream gf_stream_by_hand;
  gf_stream_by_hand<<matsubara_mesh(beta,nfreq)<<alps::gf::index_mesh(2);
  for(int i=0;i<nfreq;++i){
    gf_stream_by_hand<<(2*i+1)*M_PI/beta<<" 0 0 0 0 "<<std::endl;
  }
  EXPECT_EQ(gf_stream_by_hand.str(), gf_stream.str());
}
TEST_F(TwoIndexGFTest,Assign)
{
    namespace g=alps::gf;
    g::omega_sigma_gf other_gf(matsubara_mesh(beta, nfreq*2), g::index_mesh(nspins));
    const g::matsubara_index omega(4);
    const g::index sigma(0);
    const std::complex<double> data(3,4);
    gf(omega,sigma)=data;
    
    gf2=gf;
    EXPECT_EQ(data, gf2(omega,sigma));
    EXPECT_THROW(other_gf=gf, std::invalid_argument);
    // EXPECT_EQ(data, other_gf(omega,sigma));
}