Fixed invalid conversion in operator|(Variant, char*) (fixes #1432)

This commit is contained in:
Benoit Blanchon
2020-11-09 09:13:12 +01:00
parent bcdf5b7e52
commit 30da920135
3 changed files with 30 additions and 3 deletions

View File

@ -137,6 +137,20 @@ TEST_CASE("JsonVariant::operator|()") {
REQUIRE(result == "not default");
}
SECTION("const char* | char*") {
char dflt[] = "default";
variant.set("not default");
std::string result = variant | dflt;
REQUIRE(result == "not default");
}
SECTION("int | char*") {
char dflt[] = "default";
variant.set(42);
std::string result = variant | dflt;
REQUIRE(result == "default");
}
SECTION("const char* | int") {
variant.set("not default");
int result = variant | 42;