Esempio n. 1
0
File: svg.cpp Progetto: ogdf/ogdf
void createDocument(GraphAttributes attr, pugi::xml_document &doc, GraphIO::SVGSettings *settings = nullptr, bool reassignPositions = true) {
	std::ostringstream write;

	if(reassignPositions) {
		int i = 0;
		for(node v : attr.constGraph().nodes) {
			attr.x(v) = attr.y(v) = i++ * 100;
			attr.width(v) = attr.height(v) = 10;
		}
	}

	if(settings == nullptr) {
		GraphIO::drawSVG(attr, write);
	} else {
		GraphIO::drawSVG(attr, write, *settings);
	}

	pugi::xml_parse_result result =  doc.load_string(write.str().c_str());
	AssertThat((bool) result, IsTrue());
}
Esempio n. 2
0
	virtual void Run()
	{
		Given("an entity component store with added entities and with components", [&]() 
		{
			m_entityComponentStore = ecs::EntityComponentStore<int>();
			m_actualEntities = std::vector<int>();

			m_entities = { 1, 2, 3, 4, 5 };
			for (auto entity : m_entities)
				m_entityComponentStore.addEntity(entity);

			m_entitiesWithStringComponent.push_back(m_entities[2]);
			m_entitiesWithIntComponent.push_back(m_entities[2]);
			m_entitiesWithIntComponent.push_back(m_entities[3]);

			m_expectedStringComponentValue = std::string("test_component1");
			m_expectedIntComponentValue = 7;

			for (auto entity : m_entitiesWithStringComponent)
				m_entityComponentStore.addComponent(entity, m_expectedStringComponentValue);

			for (auto entity : m_entitiesWithIntComponent)
				m_entityComponentStore.addComponent(entity, m_expectedIntComponentValue);
		});
		Then("getting the string component of an entity gives the expected value", [&]()
		{
			std::string component = m_entityComponentStore.getComponentOfEntity<std::string>(m_entitiesWithStringComponent[0]);
			AssertThat(component, ut11::Is::EqualTo(m_expectedStringComponentValue));
		});
		Then("getting the int component of an entity gives the expected value", [&]()
		{
			int component = m_entityComponentStore.getComponentOfEntity<int>(m_entitiesWithIntComponent[0]);
			AssertThat(component, ut11::Is::EqualTo(m_expectedIntComponentValue));
		});
		Then("getting a component of an entity that does not exist throws the expected exception", [&]()
		{
			AssertThat([&]() { m_entityComponentStore.getComponentOfEntity<std::string>(100); }, ut11::Will::Throw<ecs::EntityNotFoundException>());
		});
		Then("getting a component of an entity that does not have that component throws the expected exception", [&]()
		{
			AssertThat([&]() { m_entityComponentStore.getComponentOfEntity<std::string>(m_entities[4]); }, ut11::Will::Throw<ecs::ComponentNotFoundException>());
		});
		When("getting all entities", [&]() 
		{
			m_actualEntities = m_entityComponentStore.getAllEntities();
		});
		Then("the expected entities are returned", [&]() 
		{
			AssertThat(m_actualEntities, ut11::Is::Iterable::EquivalentTo(m_entities));
		});
		When("getting all entities with string components", [&]()
		{
			m_actualEntities = m_entityComponentStore.getAllEntitiesFor<std::string>();
		});
		Then("the expected entities are returned", [&]()
		{
			AssertThat(m_actualEntities, ut11::Is::Iterable::EquivalentTo(m_entitiesWithStringComponent));
		});
		When("getting all entities with int components", [&]()
		{
			m_actualEntities = m_entityComponentStore.getAllEntitiesFor<int>();
		});
		Then("the expected entities are returned", [&]()
		{
			AssertThat(m_actualEntities, ut11::Is::Iterable::EquivalentTo(m_entitiesWithIntComponent));
		});
	}
Esempio n. 3
0
	virtual void Run()
	{
		Given("an output stream and output", [&]()
		{
			m_actualOutput.str("");
			m_output = std::unique_ptr<ut11::out::StdOutput>(new ut11::out::StdOutput(m_actualOutput));
		});
		When("begin and end without running any tests", [&]()
		{
			m_output->Begin();
			m_output->Finish(10, 7);
		});
		Then("the output is as expected", [&]()
		{
			AssertThat(m_actualOutput.str(), ut11::Is::EqualTo("\nFinished!\nRan: 10\nSucceeded: 7\n"));
		});

		When("running a test fixture with just a Then", [&]()
		{
			m_output->Begin();
			m_output->BeginFixture("fixture");
			m_output->BeginTest();
			m_output->BeginThen("then");
			m_output->EndThen("then");
			m_output->EndTest();
			m_output->EndFixture("fixture");
			m_output->Finish(1, 1);
		});
		Then("the output is as expected", [&]()
		{
			auto stringVal = m_actualOutput.str();
			auto startOfTime = stringVal.find('[');
			auto endOfTime = stringVal.find(']');
			stringVal = stringVal.erase(startOfTime, endOfTime - startOfTime + 1);

			AssertThat(stringVal, ut11::Is::EqualTo("Fixture: fixture\n\t\t\tThen: then \n\nFinished!\nRan: 1\nSucceeded: 1\n"));
		});

		When("running two test fixtures with just a Then", [&]()
		{
			m_output->Begin();
			m_output->BeginFixture("fixture");
			m_output->BeginTest();
			m_output->BeginThen("then");
			m_output->EndThen("then");
			m_output->EndTest();
			m_output->EndFixture("fixture");
			m_output->BeginFixture("fixture2");
			m_output->BeginTest();
			m_output->BeginThen("then2");
			m_output->EndThen("then2");
			m_output->EndTest();
			m_output->EndFixture("fixture2");
			m_output->Finish(2, 2);
		});
		Then("the output is as expected", [&]()
		{
			auto stringVal = m_actualOutput.str();
			auto startOfTime = stringVal.find('[');
			auto endOfTime = stringVal.find(']');
			stringVal = stringVal.erase(startOfTime, endOfTime - startOfTime + 1);

			startOfTime = stringVal.find('[');
			endOfTime = stringVal.find(']');
			stringVal = stringVal.erase(startOfTime, endOfTime - startOfTime + 1);

			AssertThat(stringVal, ut11::Is::EqualTo("Fixture: fixture\n\t\t\tThen: then \nFixture: fixture2\n\t\t\tThen: then2 \n\nFinished!\nRan: 2\nSucceeded: 2\n"));
		});

		When("running a test fixture with just a When and Then", [&]()
		{
			m_output->Begin();
			m_output->BeginFixture("fixture");
			m_output->BeginTest();
			m_output->BeginWhen("when");
			m_output->EndWhen("then");
			m_output->BeginThen("then");
			m_output->EndThen("then");
			m_output->EndTest();
			m_output->EndFixture("fixture");
			m_output->Finish(1, 1);
		});
		Then("the output is as expected", [&]()
		{
			auto stringVal = m_actualOutput.str();
			auto startOfTime = stringVal.find('[');
			auto endOfTime = stringVal.find(']');
			stringVal = stringVal.erase(startOfTime, endOfTime - startOfTime + 1);

			AssertThat(stringVal, ut11::Is::EqualTo("Fixture: fixture\n\t\tWhen: when\n\t\t\tThen: then \n\nFinished!\nRan: 1\nSucceeded: 1\n"));
		});

		When("running a test fixture with a Given When and Then", [&]()
		{
			m_output->Begin();
			m_output->BeginFixture("fixture");
			m_output->BeginTest();
			m_output->BeginGiven("given");
			m_output->EndGiven("given");
			m_output->BeginWhen("when");
			m_output->EndWhen("then");
			m_output->BeginThen("then");
			m_output->EndThen("then");
			m_output->EndTest();
			m_output->EndFixture("fixture");
			m_output->Finish(1, 1);
		});
		Then("the output is as expected", [&]()
		{
			auto stringVal = m_actualOutput.str();
			auto startOfTime = stringVal.find('[');
			auto endOfTime = stringVal.find(']');
			stringVal = stringVal.erase(startOfTime, endOfTime - startOfTime + 1);

			AssertThat(stringVal, ut11::Is::EqualTo("Fixture: fixture\n\tGiven: given\n\t\tWhen: when\n\t\t\tThen: then \n\nFinished!\nRan: 1\nSucceeded: 1\n"));
		});

		When("running a test fixture with a Given When Then Finally", [&]()
		{
			m_output->Begin();
			m_output->BeginFixture("fixture");
			m_output->BeginTest();
			m_output->BeginGiven("given");
			m_output->EndGiven("given");
			m_output->BeginWhen("when");
			m_output->EndWhen("then");
			m_output->BeginThen("then");
			m_output->EndThen("then");
			m_output->BeginFinally("finally");
			m_output->EndFinally("finally");
			m_output->EndTest();
			m_output->EndFixture("fixture");
			m_output->Finish(1, 1);
		});
		Then("the output is as expected", [&]()
		{
			auto stringVal = m_actualOutput.str();
			auto startOfTime = stringVal.find('[');
			auto endOfTime = stringVal.find(']');
			stringVal = stringVal.erase(startOfTime, endOfTime - startOfTime + 1);

			AssertThat(stringVal, ut11::Is::EqualTo("Fixture: fixture\n\tGiven: given\n\t\tWhen: when\n\t\t\tThen: then \n\tFinally: finally\n\nFinished!\nRan: 1\nSucceeded: 1\n"));
		});

		When("running a test fixture with multiple tests with a Given When Then Finally where the Given and Whens repeat", [&]()
		{
			m_output->Begin();
			m_output->BeginFixture("fixture");
			m_output->BeginTest();
			m_output->BeginGiven("given");
			m_output->EndGiven("given");
			m_output->BeginWhen("when");
			m_output->EndWhen("then");
			m_output->BeginThen("then");
			m_output->EndThen("then");
			m_output->BeginFinally("finally");
			m_output->EndFinally("finally");
			m_output->EndTest();
			m_output->BeginTest();
			m_output->BeginGiven("given");
			m_output->EndGiven("given");
			m_output->BeginWhen("when");
			m_output->EndWhen("then");
			m_output->BeginThen("then2");
			m_output->EndThen("then2");
			m_output->BeginFinally("finally");
			m_output->EndFinally("finally");
			m_output->EndTest();
			m_output->EndFixture("fixture");
			m_output->Finish(1, 1);
		});
		Then("the output is as expected", [&]()
		{
			auto stringVal = m_actualOutput.str();
			auto startOfTime = stringVal.find('[');
			auto endOfTime = stringVal.find(']');
			stringVal = stringVal.erase(startOfTime, endOfTime - startOfTime + 1);

			startOfTime = stringVal.find('[');
			endOfTime = stringVal.find(']');
			stringVal = stringVal.erase(startOfTime, endOfTime - startOfTime + 1);

			AssertThat(stringVal, ut11::Is::EqualTo("Fixture: fixture\n\tGiven: given\n\t\tWhen: when\n\t\t\tThen: then \n\t\t\tThen: then2 \n\tFinally: finally\n\nFinished!\nRan: 1\nSucceeded: 1\n"));
		});

		When("running a test fixture with a When Then Finally", [&]()
		{
			m_output->Begin();
			m_output->BeginFixture("fixture");
			m_output->BeginTest();
			m_output->BeginWhen("when");
			m_output->EndWhen("then");
			m_output->BeginThen("then");
			m_output->EndThen("then");
			m_output->BeginFinally("finally");
			m_output->EndFinally("finally");
			m_output->EndTest();
			m_output->EndFixture("fixture");
			m_output->Finish(1, 1);
		});
		Then("the output is as expected", [&]()
		{
			auto stringVal = m_actualOutput.str();
			auto startOfTime = stringVal.find('[');
			auto endOfTime = stringVal.find(']');
			stringVal = stringVal.erase(startOfTime, endOfTime - startOfTime + 1);

			AssertThat(stringVal, ut11::Is::EqualTo("Fixture: fixture\n\t\tWhen: when\n\t\t\tThen: then \n\tFinally: finally\n\nFinished!\nRan: 1\nSucceeded: 1\n"));
		});

		When("running a test fixture with a Then Finally", [&]()
		{
			m_output->Begin();
			m_output->BeginFixture("fixture");
			m_output->BeginTest();
			m_output->BeginThen("then");
			m_output->EndThen("then");
			m_output->BeginFinally("finally");
			m_output->EndFinally("finally");
			m_output->EndTest();
			m_output->EndFixture("fixture");
			m_output->Finish(1, 1);
		});
		Then("the output is as expected", [&]()
		{
			auto stringVal = m_actualOutput.str();
			auto startOfTime = stringVal.find('[');
			auto endOfTime = stringVal.find(']');
			stringVal = stringVal.erase(startOfTime, endOfTime - startOfTime + 1);

			AssertThat(stringVal, ut11::Is::EqualTo("Fixture: fixture\n\t\t\tThen: then \n\tFinally: finally\n\nFinished!\nRan: 1\nSucceeded: 1\n"));
		});

		When("running a test fixture with a Given When Then Finally and the Then fails with an std::exception", [&]()
		{
			m_output->Begin();
			m_output->BeginFixture("fixture");
			m_output->BeginTest();
			m_output->BeginGiven("given");
			m_output->EndGiven("given");
			m_output->BeginWhen("when");
			m_output->EndWhen("then");
			m_output->BeginThen("then");
			m_output->OnError(std::runtime_error("error"));
			m_output->EndThen("then");
			m_output->BeginFinally("finally");
			m_output->EndFinally("finally");
			m_output->EndTest();
			m_output->EndFixture("fixture");
			m_output->Finish(1, 0);
		});
		Then("the output is as expected", [&]()
		{
			auto stringVal = m_actualOutput.str();
			auto startOfTime = stringVal.find('[');
			startOfTime = stringVal.substr(startOfTime + 1).find('[') + startOfTime;

			auto endOfTime = stringVal.find(']');
			endOfTime = stringVal.substr(endOfTime + 1).find(']') + endOfTime + 1;

			stringVal = stringVal.erase(startOfTime, endOfTime - startOfTime + 1);

			AssertThat(stringVal, ut11::Is::EqualTo("Fixture: fixture\n\tGiven: given\n\t\tWhen: when\n\t\t\tThen: then\n\tFailed: std::exception was thrown [what(): error]\n\tFinally: finally\n\nFinished!\nRan: 1\nSucceeded: 0\n"));
		});

		When("running a test fixture with a Given When Then Finally and the Then fails with an unknown error", [&]()
		{
			m_output->Begin();
			m_output->BeginFixture("fixture");
			m_output->BeginTest();
			m_output->BeginGiven("given");
			m_output->EndGiven("given");
			m_output->BeginWhen("when");
			m_output->EndWhen("then");
			m_output->BeginThen("then");
			m_output->OnUnknownError();
			m_output->EndThen("then");
			m_output->BeginFinally("finally");
			m_output->EndFinally("finally");
			m_output->EndTest();
			m_output->EndFixture("fixture");
			m_output->Finish(1, 0);
		});
		Then("the output is as expected", [&]()
		{
			auto stringVal = m_actualOutput.str();
			auto startOfTime = stringVal.find('[');
			startOfTime = stringVal.substr(startOfTime + 1).find('[') + startOfTime;

			auto endOfTime = stringVal.find(']');
			endOfTime = stringVal.substr(endOfTime + 1).find(']') + endOfTime + 1;

			stringVal = stringVal.erase(startOfTime, endOfTime - startOfTime + 1);

			AssertThat(stringVal, ut11::Is::EqualTo("Fixture: fixture\n\tGiven: given\n\t\tWhen: when\n\t\t\tThen: then\n\tFailed: Unknown Error\n\tFinally: finally\n\nFinished!\nRan: 1\nSucceeded: 0\n"));
		});

		When("running a test fixture with a Given When Then Finally and the Then fails", [&]()
		{
			m_output->Begin();
			m_output->BeginFixture("fixture");
			m_output->BeginTest();
			m_output->BeginGiven("given");
			m_output->EndGiven("given");
			m_output->BeginWhen("when");
			m_output->EndWhen("then");
			m_output->BeginThen("then");
			m_output->OnError(10, "file", "error");
			m_output->EndThen("then");
			m_output->BeginFinally("finally");
			m_output->EndFinally("finally");
			m_output->EndTest();
			m_output->EndFixture("fixture");
			m_output->Finish(1, 0);
		});
		Then("the output is as expected", [&]()
		{
			auto stringVal = m_actualOutput.str();
			auto startOfTime = stringVal.find('[');
			startOfTime = stringVal.substr(startOfTime + 1).find('[') + startOfTime;

			auto endOfTime = stringVal.find(']');
			endOfTime = stringVal.substr(endOfTime + 1).find(']') + endOfTime + 1;

			stringVal = stringVal.erase(startOfTime, endOfTime - startOfTime + 1);

			AssertThat(stringVal, ut11::Is::EqualTo("Fixture: fixture\n\tGiven: given\n\t\tWhen: when\n\t\t\tThen: then\n\tFailed: [10:file] error\n\tFinally: finally\n\nFinished!\nRan: 1\nSucceeded: 0\n"));
		});


		When("running a test fixture with a Given When Finally and the When fails", [&]()
		{
			m_output->Begin();
			m_output->BeginFixture("fixture");
			m_output->BeginTest();
			m_output->BeginGiven("given");
			m_output->EndGiven("given");
			m_output->BeginWhen("when");
			m_output->OnError(10, "file", "error");
			m_output->EndWhen("then");
			m_output->BeginFinally("finally");
			m_output->EndFinally("finally");
			m_output->EndTest();
			m_output->EndFixture("fixture");
			m_output->Finish(1, 0);
		});
		Then("the output is as expected", [&]()
		{
			auto stringVal = m_actualOutput.str();
			auto startOfTime = stringVal.find('[');
			startOfTime = stringVal.substr(startOfTime + 1).find('[') + startOfTime;

			auto endOfTime = stringVal.find(']');
			endOfTime = stringVal.substr(endOfTime + 1).find(']') + endOfTime + 1;

			stringVal = stringVal.erase(startOfTime, endOfTime - startOfTime + 1);

			AssertThat(stringVal, ut11::Is::EqualTo("Fixture: fixture\n\tGiven: given\n\t\tWhen: when\n\tFailed: [10:file] error\n\tFinally: finally\n\nFinished!\nRan: 1\nSucceeded: 0\n"));
		});


		When("running a test fixture with a Given Finally and the Given fails", [&]()
		{
			m_output->Begin();
			m_output->BeginFixture("fixture");
			m_output->BeginTest();
			m_output->BeginGiven("given");
			m_output->OnError(10, "file", "error");
			m_output->EndGiven("given");
			m_output->BeginFinally("finally");
			m_output->EndFinally("finally");
			m_output->EndTest();
			m_output->EndFixture("fixture");
			m_output->Finish(1, 0);
		});
		Then("the output is as expected", [&]()
		{
			auto stringVal = m_actualOutput.str();
			auto startOfTime = stringVal.find('[');
			startOfTime = stringVal.substr(startOfTime + 1).find('[') + startOfTime;

			auto endOfTime = stringVal.find(']');
			endOfTime = stringVal.substr(endOfTime + 1).find(']') + endOfTime + 1;

			stringVal = stringVal.erase(startOfTime, endOfTime - startOfTime + 1);

			AssertThat(stringVal, ut11::Is::EqualTo("Fixture: fixture\n\tGiven: given\n\tFailed: [10:file] error\n\tFinally: finally\n\nFinished!\nRan: 1\nSucceeded: 0\n"));
		});

		When("running a test fixture with a Given Finally and the Finally fails", [&]()
		{
			m_output->Begin();
			m_output->BeginFixture("fixture");
			m_output->BeginTest();
			m_output->BeginGiven("given");
			m_output->EndGiven("given");
			m_output->BeginFinally("finally");
			m_output->OnError(10, "file", "error");
			m_output->EndFinally("finally");
			m_output->EndTest();
			m_output->EndFixture("fixture");
			m_output->Finish(1, 0);
		});
		Then("the output is as expected", [&]()
		{
			auto stringVal = m_actualOutput.str();
			auto startOfTime = stringVal.find('[');
			startOfTime = stringVal.substr(startOfTime + 1).find('[') + startOfTime;

			auto endOfTime = stringVal.find(']');
			endOfTime = stringVal.substr(endOfTime + 1).find(']') + endOfTime + 1;

			stringVal = stringVal.erase(startOfTime, endOfTime - startOfTime + 1);

			AssertThat(stringVal, ut11::Is::EqualTo("Fixture: fixture\n\tGiven: given\n\tFinally: finally\n\tFailed: [10:file] error\n\nFinished!\nRan: 1\nSucceeded: 0\n"));
		});
	}
Esempio n. 4
0
File: assert.cpp Progetto: ogdf/ogdf
		});
#endif

#ifdef OGDF_USE_ASSERT_EXCEPTIONS
		it("throws an AssertionFailed exception if the condition does not hold", [] {
			AssertThrows(AssertionFailed, assert_positive(-1));
		});

		it("throws an exception with an explanatory what()", [] {
			int fails = false;
			try {
				assert_positive(-1);
			} catch (AssertionFailed &e) {
				fails = true;
				std::string what(e.what());
				AssertThat(what, Contains("a > 0"));
				AssertThat(what, Contains("fail"));
				AssertThat(what, Contains(__FILE__ ":1000"));
				AssertThat(what, Contains("assert_positive"));
			}
			AssertThat(fails, IsTrue());
		});
#endif

#ifdef OGDF_USE_ASSERT_EXCEPTIONS_WITH_STACKTRACE
		it("throws an exception with a stack trace in what()", [] {
			int fails = false;
			try {
				assert_positive(-1);
			} catch (AssertionFailed &e) {
				fails = true;
	virtual void Run(){

		Given("a MockReturnHandler", [&]() {

			m_returner = ut11::detail::MockReturnHandler<int, char>();
		});

		When("calling the MockReturnHandler", [&]() {

			m_expectedReturnValue = ut11::utility::DefaultValue<int>()();

			m_returnedValue = m_returner.operator ()('A');
		});

		Then("the return value is the expected value", [&]() {

			AssertThat(m_returnedValue, ut11::Is::EqualTo(m_expectedReturnValue));
		});

		When("setting the value to be returned and calling the MockReturnHandler", [&]() {

			m_expectedReturnValue = 32;
			m_returner.SetReturn(m_expectedReturnValue);

			m_returnedValue = m_returner.operator ()('A');

		});

		Then("the return value is the expected value", [&]() {

			AssertThat(m_returnedValue, ut11::Is::EqualTo(m_expectedReturnValue));
		});


		When("setting the a return function and calling the MockReturnHandler", [&]() {

			m_expectedReturnValue = 32;
			m_expectedArgument = 'Z';

			m_returner.SetReturn([&](char actual)
			{
				m_actualArgument = actual;
				return m_expectedReturnValue;
			});

			m_returnedValue = m_returner.operator ()(m_expectedArgument);

		});

		Then("the return value is the expected value", [&]() {

			AssertThat(m_returnedValue, ut11::Is::EqualTo(m_expectedReturnValue));
		});


		Then("the argument passed in to the return function is the expected value", [&]() {

			AssertThat(m_actualArgument, ut11::Is::EqualTo(m_expectedArgument));
		});

		When("setting the a return value, overriding that with a return function and calling the MockReturnHandler", [&]() {

			m_expectedReturnValue = 32;
			m_expectedArgument = 'Z';

			m_returner.SetReturn('A');
			m_returner.SetReturn([&](char actual)
			{
				m_actualArgument = actual;
				return m_expectedReturnValue;
			});

			m_returnedValue = m_returner.operator ()(m_expectedArgument);

		});

		Then("the return value is the expected value", [&]() {

			AssertThat(m_returnedValue, ut11::Is::EqualTo(m_expectedReturnValue));
		});


		Then("the argument passed in to the return function is the expected value", [&]() {

			AssertThat(m_actualArgument, ut11::Is::EqualTo(m_expectedArgument));
		});

		When("setting the a return function, overriding that with a return value and calling the MockReturnHandler", [&]() {

			m_expectedReturnValue = 32;

			m_returner.SetReturn([&](char) { return 21; });
			m_returner.SetReturn(m_expectedReturnValue);

			m_returnedValue = m_returner.operator ()(m_expectedArgument);

		});

		Then("the return value is the expected value", [&]() {

			AssertThat(m_returnedValue, ut11::Is::EqualTo(m_expectedReturnValue));
		});
	}
Esempio n. 6
0
//
// Output a single byte, leaving line in an idle state.
//
void TestOne()
{
    AssertThat( txState == true,   "Idle state incorrect" );

    //
    // Check the record we read back.
    //
    UARTTransmitByte( 0x55 );

    //
    //
    //
    UARTTransmitHandler();
    AssertThat( txState == false,   "Start state incorrect" );

    UARTTransmitHandler();
    AssertThat( txState == true,   "Bit0 state incorrect" );

    UARTTransmitHandler();
    AssertThat( txState == false,  "Bit1 state incorrect" );

    UARTTransmitHandler();
    AssertThat( txState == true,   "Bit2 state incorrect" );

    UARTTransmitHandler();
    AssertThat( txState == false,  "Bit3 state incorrect" );

    UARTTransmitHandler();
    AssertThat( txState == true,   "Bit4 state incorrect" );

    UARTTransmitHandler();
    AssertThat( txState == false,  "Bit5 state incorrect" );

    UARTTransmitHandler();
    AssertThat( txState == true,   "Bit6 state incorrect" );

    UARTTransmitHandler();
    AssertThat( txState == false,  "Bit7 state incorrect" );

    UARTTransmitHandler();
    AssertThat( txState == true,   "Stop state incorrect" );

    UARTTransmitHandler();
    AssertThat( txState == true,   "Idle state incorrect" );
}
Esempio n. 7
0
File: svg.cpp Progetto: ogdf/ogdf
describe("SVG", []() {
	std::unique_ptr<Graph> graph;
	int numberOfNodes = 42;

	before_each([&](){
		graph.reset(new Graph);
		randomBiconnectedGraph(*graph, numberOfNodes, 3*numberOfNodes);
	});

	it("is well-formed", [&]() {
		GraphAttributes attr(*graph);
		pugi::xml_document doc;
		createDocument(attr, doc);

		pugi::xml_node svg = doc.child("svg");
		AssertThat((bool) svg, IsTrue());
		AssertThat(svg.attribute("viewBox").empty(), IsFalse());

		AssertThat(static_cast<int>(svg.select_nodes("//rect").size()), Equals(graph->numberOfNodes()));
		AssertThat(static_cast<int>(svg.select_nodes("//path").size()), Equals(graph->numberOfEdges()));
	});

	it("supports 3D", [&]() {
		GraphAttributes attr(*graph,
				GraphAttributes::nodeGraphics |
				GraphAttributes::nodeStyle |
				GraphAttributes::edgeGraphics |
				GraphAttributes::threeD |
				GraphAttributes::nodeLabel |
				GraphAttributes::nodeLabelPosition);
		List<node> nodes;
Esempio n. 8
0
				perms.calcAll(&P,&allPerms);

				for (int i = 1; i < 10; i++){
					Graph G;
					randomSimpleGraph(G,N,1*N);

					//make an instance for the MAOs
					MaxAdjOrdering m;

					//make structures for saving all MAOs of G
					ListPure<ListPure<node>> MAOs;

					//calculate them
					m.calcAll(&G,&MAOs);

					AssertThat(m.testIfAllMAOs(&G,&MAOs,&allPerms), IsTrue());
				}
			}
		});
		it("should calculate MAOs with correct lex-bfs tie breaking", [](){
			for (int N = 10; N <= 20; N++){
				std::cout << "    " << "Busy with graphs that have " << N << " nodes." << std::endl;

				for (int i = 1; i < 10; i++){
					Graph G;
					randomSimpleGraph(G, N, (N*(N-4))/2);

					//make an instance for the MAOs
					MaxAdjOrdering m;

					//make structures for saving all MAOs of G