2023-01-09 17:31:13 +00:00
|
|
|
#include "TestFramework.h"
|
|
|
|
#include "TestUtils.h"
|
|
|
|
|
|
|
|
#include "BlochSphereNode.h"
|
|
|
|
#include "BlochSphere.h"
|
|
|
|
#include "Scene.h"
|
|
|
|
|
|
|
|
#include "SvgConverter.h"
|
|
|
|
#include "SvgWriter.h"
|
2023-01-10 09:28:15 +00:00
|
|
|
#include "SvgDocument.h"
|
2023-01-09 17:31:13 +00:00
|
|
|
|
|
|
|
#include "File.h"
|
|
|
|
|
|
|
|
TEST_CASE(TestBlochSphereNode, "quantum_computing")
|
|
|
|
{
|
2023-01-11 10:21:18 +00:00
|
|
|
auto node = std::make_unique<BlochSphereNode>(Point(0.5, 0.5));
|
2023-01-09 17:31:13 +00:00
|
|
|
|
|
|
|
Qubit state({ 1.0, 0.0 }, { 0.0, 0.0 });
|
|
|
|
|
|
|
|
auto bloch_sphere = std::make_unique<BlochSphere>(state);
|
|
|
|
|
|
|
|
node->setContent(bloch_sphere.get());
|
|
|
|
|
|
|
|
auto scene = std::make_unique<Scene>();
|
|
|
|
scene->addNode(node.get());
|
|
|
|
scene->update();
|
|
|
|
|
|
|
|
SvgConverter converter;
|
|
|
|
auto svg_document = converter.convert(scene.get());
|
|
|
|
|
|
|
|
SvgWriter writer;
|
|
|
|
auto svg_content = writer.toString(svg_document.get());
|
|
|
|
|
|
|
|
File svg_file(TestUtils::getTestOutputDir(__FILE__) / "bloch_sphere.svg");
|
|
|
|
svg_file.writeText(svg_content);
|
|
|
|
}
|