Commit 7a7e467e authored by Powers, Sarah's avatar Powers, Sarah
Browse files

Initial commit NoiseAwareTransformationTester.cpp

parent 462d4155
Loading
Loading
Loading
Loading
Loading
+29 −1
Original line number Diff line number Diff line
@@ -4,11 +4,39 @@
#include "XACC.hpp"
#include "qcor.hpp"
#include "xacc_service.hpp"
#include CNOT.hpp

using namespace qcor;
using namespace qcor::transformations;

// TEST() {} //TODO
// first way
const std::string uccsdSrc = R"uccsdSrc(def foo():
  H(0)
  CNOT(0,1)
  )uccsdSrc";

TEST(NoiseAwareTransformationTester, checkSimple ) {
    
    if (xacc::hasCompiler("xacc-py")) {
        auto c = xacc::getService<xacc::Compiler>("xacc-py");
        auto f = c->compile("def foo(buffer):\n   H(0)\n   CNOT(0,1)\n")
                 ->getKernels()[0];
        auto ir = std::make_shared<GateIR>();
        ir->addKernel(f);
        
        NoiseAwareTransformation nat;
        auto newir = opt.transform(ir);
        auto natF = newir->getKernels()[0];
        
        EXPECT_EQ(2, natF->nInstructions());
        
        EXPECT_EQ(std::vector<int>{1}, natF->getInstruction(0)->bits());
        EXPECT_EQ(std::vector<int>{0,1}, natF->getInstruction(1)->bits());

}

  
  
  
int main(ing argc, char **argv) {
  qcor::Initialize(argc, argv);