Project Cube Solver #05 – Face turn metrics – code and tests

Project Cube Solver #05 – Face turn metrics – code and tests

I hope you have read my previous post. If no, it will be better if you do it before because code that we will write today will be better understood for you then.

Article is also available in Polish version.

Tests for HTM metric

So, let’s start from HTM metric which is really simple metric.
First of our tests will checks if name of metric is correct:

Second one will checks if value for given moves is valid:

And the last one checks if scramble with some moves has proper number of moves:

Tests for QTMmetric

Our next goal is to write test for QTM metric. I show them below.

First of them that checks if metric has valid name:

Second test that checks if given moves has valid value:

And last one that checks if length of scramble is valid:

Implementation of metrics classes

And now all we need is to write our classes which will count length of our scrambles:

This is HTM metric class:

QTM metric class:

Additionally, I created abstract class which has shared code for my both metric class. Of course my tests help me to do it without needless pain.
And this is it:

Now, if we run our tests, all of them should pass.
You can see my changes here. You can of course download my project from there if you like it.

What next

In next episode of my project I will start to creating class responsible for cube and moves on it.

Leave a Reply

Your email address will not be published. Required fields are marked *