File: fixture.h

package info (click to toggle)
libcds 2.3.3-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 15,564 kB
  • sloc: cpp: 135,002; ansic: 7,218; perl: 243; sh: 237; makefile: 6
file content (37 lines) | stat: -rw-r--r-- 920 bytes parent folder | download | duplicates (3)
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
// Copyright (c) 2006-2018 Maxim Khizhinsky
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE or copy at http://www.boost.org/LICENSE_1_0.txt)

#ifndef CDSTEST_FIXTURE_H
#define CDSTEST_FIXTURE_H

#include <cds_test/ext_gtest.h>
#include <algorithm>
#include <random>

namespace cds_test {

    class fixture : public ::testing::Test
    {
    public:
        template <typename RandomIt>
        static void shuffle( RandomIt first, RandomIt last )
        {
            std::shuffle( first, last, random_gen_ );
        }

        static unsigned int rand( unsigned int nMax )
        {
            std::uniform_int_distribution<unsigned> dis(0, nMax - 1);
            return dis( random_gen_ );
        }

    private:
        static std::random_device random_dev_;
        static std::mt19937 random_gen_;
    };

} // namespace cds_test

#endif // CDSTEST_FIXTURE_H