|
| 1 | +#include "InternalEvent.h" |
| 2 | +#include <omp-tools.h> |
| 3 | +#include <sstream> |
| 4 | + |
| 5 | +#include "gtest/gtest.h" |
| 6 | + |
| 7 | +using namespace omptest; |
| 8 | + |
| 9 | +TEST(InternalEvent_equality_ops, Dispatch_identity) { |
| 10 | + ompt_data_t DI{.value = 31}; |
| 11 | + internal::Dispatch D{/*ParallelData=*/(ompt_data_t *)0x11, |
| 12 | + /*TaskData=*/(ompt_data_t *)0x22, |
| 13 | + /*Kind=*/ompt_dispatch_t::ompt_dispatch_iteration, |
| 14 | + /*Instance=*/DI}; |
| 15 | + |
| 16 | + EXPECT_EQ(D == D, true); |
| 17 | +} |
| 18 | + |
| 19 | +TEST(InternalEvent_equality_ops, Dispatch_same) { |
| 20 | + ompt_data_t DI{.ptr = (void *)0x33}; |
| 21 | + internal::Dispatch D1{/*ParallelData=*/(ompt_data_t *)0x11, |
| 22 | + /*TaskData=*/(ompt_data_t *)0x22, |
| 23 | + /*Kind=*/ompt_dispatch_t::ompt_dispatch_section, |
| 24 | + /*Instance=*/DI}; |
| 25 | + |
| 26 | + internal::Dispatch D2{/*ParallelData=*/(ompt_data_t *)0x11, |
| 27 | + /*TaskData=*/(ompt_data_t *)0x22, |
| 28 | + /*Kind=*/ompt_dispatch_t::ompt_dispatch_section, |
| 29 | + /*Instance=*/DI}; |
| 30 | + |
| 31 | + EXPECT_EQ(D1 == D2, true); |
| 32 | +} |
| 33 | + |
| 34 | +TEST(InternalEvent_equality_ops, Dispatch_different_kind) { |
| 35 | + ompt_data_t DI{.ptr = (void *)0x33}; |
| 36 | + internal::Dispatch D1{/*ParallelData=*/(ompt_data_t *)0x11, |
| 37 | + /*TaskData=*/(ompt_data_t *)0x22, |
| 38 | + /*Kind=*/ompt_dispatch_t::ompt_dispatch_section, |
| 39 | + /*Instance=*/DI}; |
| 40 | + |
| 41 | + internal::Dispatch D2{/*ParallelData=*/(ompt_data_t *)0x11, |
| 42 | + /*TaskData=*/(ompt_data_t *)0x22, |
| 43 | + /*Kind=*/ompt_dispatch_t::ompt_dispatch_iteration, |
| 44 | + /*Instance=*/DI}; |
| 45 | + |
| 46 | + // Demonstrate that 'Kind' is the only relevant field for equality. |
| 47 | + EXPECT_EQ(D1 == D2, false); |
| 48 | +} |
| 49 | + |
| 50 | +TEST(InternalEvent_equality_ops, Dispatch_same_kind_different_other) { |
| 51 | + ompt_data_t DI1{.ptr = (void *)0x33}; |
| 52 | + internal::Dispatch D1{/*ParallelData=*/(ompt_data_t *)0x11, |
| 53 | + /*TaskData=*/(ompt_data_t *)0x22, |
| 54 | + /*Kind=*/ompt_dispatch_t::ompt_dispatch_section, |
| 55 | + /*Instance=*/DI1}; |
| 56 | + |
| 57 | + ompt_data_t DI2{.ptr = (void *)0x66}; |
| 58 | + internal::Dispatch D2{/*ParallelData=*/(ompt_data_t *)0x44, |
| 59 | + /*TaskData=*/(ompt_data_t *)0x55, |
| 60 | + /*Kind=*/ompt_dispatch_t::ompt_dispatch_section, |
| 61 | + /*Instance=*/DI2}; |
| 62 | + |
| 63 | + // Demonstrate that 'Kind' is the only relevant field for equality. |
| 64 | + EXPECT_EQ(D1 == D2, true); |
| 65 | +} |
0 commit comments