Skip to content

Commit

Permalink
[eclipse-iceoryx#264] Basic test setup created
Browse files Browse the repository at this point in the history
  • Loading branch information
elfenpiff committed Sep 9, 2024
1 parent cb147a0 commit 2029834
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
3 changes: 2 additions & 1 deletion iceoryx2-ffi/cxx/include/iox2/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#ifndef IOX2_CONFIG_HPP
#define IOX2_CONFIG_HPP

#include "iox/expected.hpp"
#include "iox/file_name.hpp"
#include "iox2/internal/iceoryx2.hpp"

Expand All @@ -23,7 +24,7 @@ namespace config {
class Global {
public:
auto prefix() && -> const char*;
auto set_prefix(const char* value) &&;
void set_prefix(const iox::FileName& value) &&;

private:
friend class ::iox2::Config;
Expand Down
4 changes: 2 additions & 2 deletions iceoryx2-ffi/cxx/src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ auto Global::prefix() && -> const char* {
return iox2_config_global_prefix(ref_handle);
}

auto Global::set_prefix(const char* value) && {
void Global::set_prefix(const iox::FileName& value) && {
auto* ref_handle = iox2_cast_config_ref_h(m_config->m_handle);
iox2_config_global_set_prefix(ref_handle, value);
iox2_config_global_set_prefix(ref_handle, value.as_string().c_str());
}
} // namespace config
} // namespace iox2
27 changes: 27 additions & 0 deletions iceoryx2-ffi/cxx/tests/src/config_tests.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright (c) 2024 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

#include "iox2/config.hpp"

#include "test.hpp"

namespace {
using namespace iox2;

TEST(Config, global_prefix_works) {
const auto test_value = iox::FileName::create("oh_my_dot").expect("");
auto config = Config();

config.global().set_prefix(test_value);
ASSERT_THAT(config.global().prefix(), StrEq(test_value.as_string().c_str()));
}
} // namespace

0 comments on commit 2029834

Please sign in to comment.