-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #55 from elfenpiff/iox2-16-same-name-different-mes…
…saging-pattern-allowed [#16] same name different messaging pattern allowed
- Loading branch information
Showing
6 changed files
with
94 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// Copyright (c) 2023 Contributors to the Eclipse Foundation | ||
// | ||
// See the NOTICE file(s) distributed with this work for additional | ||
// information regarding copyright ownership. | ||
// | ||
// This program and the accompanying materials are made available under the | ||
// terms of the Apache Software License 2.0 which is available at | ||
// https://www.apache.org/licenses/LICENSE-2.0, or the MIT license | ||
// which is available at https://opensource.org/licenses/MIT. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
||
#[generic_tests::define] | ||
mod service { | ||
use iceoryx2::port::event_id::EventId; | ||
use iceoryx2::service::{service_name::ServiceName, Service}; | ||
use iceoryx2_bb_posix::unique_system_id::UniqueSystemId; | ||
use iceoryx2_bb_testing::assert_that; | ||
|
||
fn generate_name() -> ServiceName { | ||
ServiceName::new(&format!( | ||
"service_tests_{}", | ||
UniqueSystemId::new().unwrap().value() | ||
)) | ||
.unwrap() | ||
} | ||
|
||
#[test] | ||
fn same_name_with_different_messaging_pattern_is_allowed<Sut: Service>() { | ||
let service_name = generate_name(); | ||
let sut_pub_sub = Sut::new(&service_name).publish_subscribe().create::<u64>(); | ||
assert_that!(sut_pub_sub, is_ok); | ||
let sut_pub_sub = sut_pub_sub.unwrap(); | ||
|
||
let sut_event = Sut::new(&service_name).event().create(); | ||
assert_that!(sut_event, is_ok); | ||
let sut_event = sut_event.unwrap(); | ||
|
||
let sut_subscriber = sut_pub_sub.subscriber().create().unwrap(); | ||
let sut_publisher = sut_pub_sub.publisher().create().unwrap(); | ||
|
||
let mut sut_listener = sut_event.listener().create().unwrap(); | ||
let sut_notifier = sut_event.notifier().create().unwrap(); | ||
|
||
const SAMPLE_VALUE: u64 = 891231211; | ||
sut_publisher.send_copy(SAMPLE_VALUE).unwrap(); | ||
let received_sample = sut_subscriber.receive().unwrap().unwrap(); | ||
assert_that!(*received_sample, eq SAMPLE_VALUE); | ||
|
||
const EVENT_ID: EventId = EventId::new(10123101301); | ||
sut_notifier.notify_with_custom_event_id(EVENT_ID).unwrap(); | ||
let received_event = sut_listener.try_wait().unwrap(); | ||
assert_that!(received_event, len 1); | ||
assert_that!(received_event[0], eq EVENT_ID); | ||
} | ||
|
||
#[instantiate_tests(<iceoryx2::service::zero_copy::Service>)] | ||
mod zero_copy {} | ||
|
||
#[instantiate_tests(<iceoryx2::service::process_local::Service>)] | ||
mod process_local {} | ||
} |