DWKernelTester.cpp 1.48 KB
Newer Older
1
2
3
4
5
6
7
8
/*******************************************************************************
 * Copyright (c) 2017 UT-Battelle, LLC.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * and Eclipse Distribution License v1.0 which accompanies this
 * distribution. The Eclipse Public License is available at
 * http://www.eclipse.org/legal/epl-v10.html and the Eclipse Distribution License
 * is available at https://eclipse.org/org/documents/edl-v10.php
9
10
 *
 * Contributors:
11
12
 *   Alexander J. McCaskey - initial API and implementation
 *******************************************************************************/
13
#define BOOST_TEST_DYN_LINK
14
#define BOOST_TEST_MODULE DWKernelTester
15
16

#include <boost/test/included/unit_test.hpp>
17
#include "DWKernel.hpp"
18
19
20

using namespace xacc::quantum;

21
BOOST_AUTO_TEST_CASE(checkDWKernelConstruction) {
22

23
24
25
	auto qmi = std::make_shared<DWQMI>(0, 1, 2.2);
	auto qmi2 = std::make_shared<DWQMI>(0);
	auto qmi3 = std::make_shared<DWQMI>(22, 3.3);
26

27
	DWKernel kernel("foo");
28
29
30
	kernel.addInstruction(qmi);
	kernel.addInstruction(qmi2);
	kernel.addInstruction(qmi3);
31

32
	BOOST_VERIFY(kernel.nInstructions() == 3);
33
	BOOST_VERIFY(kernel.name() == "foo");
34
35
36
	BOOST_VERIFY(kernel.getInstruction(0) == qmi);
	BOOST_VERIFY(kernel.getInstruction(1) == qmi2);
	BOOST_VERIFY(kernel.getInstruction(2) == qmi3);
37

38
	const std::string expected = "0 1 2.2\n0 0 0\n22 22 3.3\n";
39

40
	BOOST_VERIFY(kernel.toString("") == expected);
41
42
}