Passwordfile library  3.2.0
C++ library to read/write passwords from/to encrypted files
opensslrandomdevice.cpp
Go to the documentation of this file.
1 #include "../util/opensslrandomdevice.h"
2 
3 #include <c++utilities/tests/testutils.h>
4 
5 #include <cppunit/TestFixture.h>
6 #include <cppunit/extensions/HelperMacros.h>
7 
8 #include <random>
9 
10 using namespace std;
11 using namespace Util;
12 using namespace TestUtilities::Literals;
13 
14 using namespace CPPUNIT_NS;
15 
19 class OpenSslRandomDeviceTests : public TestFixture {
20  CPPUNIT_TEST_SUITE(OpenSslRandomDeviceTests);
21  CPPUNIT_TEST(testUsageWithStandardClasses);
22  CPPUNIT_TEST_SUITE_END();
23 
24 public:
25  void setUp();
26  void tearDown();
27 
28  void testUsageWithStandardClasses();
29 };
30 
32 
34 {
35 }
36 
38 {
39 }
40 
45 {
46  uniform_int_distribution<> dist(1, 10);
47  const Util::OpenSslRandomDevice random;
48  const auto val = dist(random);
49  CPPUNIT_ASSERT_GREATEREQUAL(1, val);
50  CPPUNIT_ASSERT_LESSEQUAL(10, val);
51 }
CPPUNIT_TEST_SUITE_REGISTRATION(OpenSslRandomDeviceTests)
STL namespace.
Contains utility classes and functions.
Definition: openssl.h:6
void testUsageWithStandardClasses()
Tests using the OpenSslRandomDevice with std::uniform_int_distribution.
Provides a random device using the OpenSSL function RAND_bytes().
The OpenSslRandomDeviceTests class tests the Util::OpenSslRandomDevice class.