Skip to content

Commit

Permalink
Merge pull request #82 from NordSecurity/null_string_test
Browse files Browse the repository at this point in the history
Add null to empty string configuration test
  • Loading branch information
Aivaras Saulius authored Aug 2, 2024
2 parents b063507 + 4f78f01 commit eae12c2
Show file tree
Hide file tree
Showing 9 changed files with 75 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions dotnet-tests/UniffiCS.BindingTests/TestNullToEmptyString.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

using uniffi.null_to_empty_string;

namespace UniffiCS.BindingTests;

public class TestNullToEmptyString
{
[Fact]
public void NullToEmptyStringWorks()
{
Assert.Equal("hello", LibGreeter.HelloWorld("hello"));
Assert.Equal("", LibGreeter.HelloWorld(null));
}
}
1 change: 1 addition & 0 deletions fixtures/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ crate-type = ["cdylib", "lib"]

[dependencies]
global-methods-class-name = { path = "global-methods-class-name" }
null-to-empty-string = { path = "null-to-empty-string" }
uniffi-cs-custom-types-builtin = { path = "custom-types-builtin" }
uniffi-cs-disposable-fixture = { path = "disposable" }
uniffi-cs-optional-parameters-fixture = { path = "optional-parameters" }
Expand Down
18 changes: 18 additions & 0 deletions fixtures/null-to-empty-string/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[package]
name = "null-to-empty-string"
version = "1.0.0"
edition = "2021"
publish = false

[lib]
crate-type = ["lib", "cdylib"]
name = "null_to_empty_string"

[dependencies]
once_cell = "1.12"
thiserror = "1.0"
uniffi = {path = "../../3rd-party/uniffi-rs/uniffi", features=["build"]}
uniffi_macros = {path = "../../3rd-party/uniffi-rs/uniffi_macros"}

[build-dependencies]
uniffi = {path = "../../3rd-party/uniffi-rs/uniffi", features=["bindgen-tests"]}
7 changes: 7 additions & 0 deletions fixtures/null-to-empty-string/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

fn main() {
uniffi::generate_scaffolding("./src/null_to_empty_string.udl").unwrap();
}
9 changes: 9 additions & 0 deletions fixtures/null-to-empty-string/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

pub fn hello_world(greet: String) -> String {
return greet;
}

uniffi::include_scaffolding!("null_to_empty_string");
7 changes: 7 additions & 0 deletions fixtures/null-to-empty-string/src/null_to_empty_string.udl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

namespace null_to_empty_string {
string hello_world(string greet);
};
4 changes: 4 additions & 0 deletions fixtures/null-to-empty-string/uniffi.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[bindings.csharp]
cdylib_name = "uniffi_fixtures"
global_methods_class_name = "LibGreeter"
null_string_to_empty = true
1 change: 1 addition & 0 deletions fixtures/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ mod uniffi_fixtures {
uniffi_trait_methods::uniffi_reexport_scaffolding!();

global_methods_class_name::uniffi_reexport_scaffolding!();
null_to_empty_string::uniffi_reexport_scaffolding!();
uniffi_cs_custom_types_builtin::uniffi_reexport_scaffolding!();
uniffi_cs_disposable::uniffi_reexport_scaffolding!();
uniffi_cs_optional_parameters::uniffi_reexport_scaffolding!();
Expand Down

0 comments on commit eae12c2

Please sign in to comment.