Electroneum
Loading...
Searching...
No Matches
apply_permutation.cpp File Reference
#include "gtest/gtest.h"
#include "common/apply_permutation.h"
Include dependency graph for apply_permutation.cpp:

Go to the source code of this file.

Functions

 TEST (apply_permutation, empty)
 TEST (apply_permutation, reorder)
 TEST (apply_permutation, bad_size)
 TEST (apply_permutation, bad_permutation)

Function Documentation

◆ TEST() [1/4]

TEST ( apply_permutation ,
bad_permutation  )

Definition at line 65 of file apply_permutation.cpp.

66{
67 std::vector<int> v = {8, 4, 6, 1, 7, 2, 4};
68 try
69 {
70 tools::apply_permutation({3, 5, 6, 1, 2, 4, 1}, v);
71 ASSERT_FALSE(true);
72 }
73 catch (const std::exception &e) {}
74}
#define ASSERT_FALSE(condition)
Definition gtest.h:1868
void apply_permutation(std::vector< size_t > permutation, const F &swap)
Here is the call graph for this function:

◆ TEST() [2/4]

TEST ( apply_permutation ,
bad_size  )

Definition at line 47 of file apply_permutation.cpp.

48{
49 std::vector<int> v_large = {8, 4, 6, 1, 7, 2, 4, 9};
50 std::vector<int> v_small = {8, 4, 6, 1, 7, 2};
51 try
52 {
53 tools::apply_permutation({3, 5, 6, 1, 2, 4, 0}, v_large);
54 ASSERT_FALSE(true);
55 }
56 catch (const std::exception &e) {}
57 try
58 {
59 tools::apply_permutation({3, 5, 6, 1, 2, 4, 0}, v_small);
60 ASSERT_FALSE(true);
61 }
62 catch (const std::exception &e) {}
63}
Here is the call graph for this function:

◆ TEST() [3/4]

TEST ( apply_permutation ,
empty  )

Definition at line 32 of file apply_permutation.cpp.

33{
34 std::vector<int> v = {};
36 ASSERT_EQ(v, std::vector<int>({}));
37}
#define ASSERT_EQ(val1, val2)
Definition gtest.h:1956
Here is the call graph for this function:

◆ TEST() [4/4]

TEST ( apply_permutation ,
reorder  )

Definition at line 39 of file apply_permutation.cpp.

40{
41 // 0 1 2 3 4 5 6
42 std::vector<int> v = {8, 4, 6, 1, 7, 2, 4};
43 tools::apply_permutation({3, 5, 6, 1, 2, 4, 0}, v);
44 ASSERT_EQ(v, std::vector<int>({1, 2, 4, 4, 6, 7, 8}));
45}
Here is the call graph for this function: