-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKnuthShuffleTests.cpp
More file actions
47 lines (40 loc) · 1.18 KB
/
KnuthShuffleTests.cpp
File metadata and controls
47 lines (40 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include "CppUnitTest.h"
#include "KnuthShuffle.h"
#include "Utilities/TestUtilities.h"
#include <vector>
#include <string>
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
using namespace std;
namespace AlgorithmsTests
{
TEST_CLASS(KnuthShuffleTests)
{
public:
TEST_METHOD(KnuthShuffle_WhenShuffleSingleElement_ExpectSameElementReturned)
{
// Arrange
auto shuffler = new KnuthShuffle();
string arr[] = { "2C" };
vector<string> list(arr, arr+8);
auto old_first_element = list[0];
// Act
shuffler->Shuffle(list);
// Assert
Assert::AreEqual<string>(list[0], old_first_element);
}
TEST_METHOD(KnuthShuffle_WhenShuffleMultipleElements_ExpectElementsShuffled)
{
// Arrange
auto shuffler = new KnuthShuffle();
string arr[] = { "2C", "3C", "4C", "5C", "6C", "7C", "8C", "9C"};
vector<string> list(arr, arr+8);
auto test_utility = new TestUtilities();
auto old_hash = test_utility->hash_vector(list);
// Act
shuffler->Shuffle(list);
// Assert
auto new_hash = test_utility->hash_vector(list);
Assert::AreNotEqual<unsigned int>(old_hash, new_hash);
}
};
}