Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove More Optional Class Testing #2139

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 17 additions & 54 deletions cpp/test/Ice/optional/AllTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1216,38 +1216,27 @@ allTests(Test::TestHelper* helper, bool)
}

{
// TODO: remove this testing for tagged classes alongside the tagged class support.
optional<OneOptionalPtr> p1;
optional<OneOptionalPtr> p3;
optional<OneOptionalPtr> p2 = initial->opOneOptional(p1, p3);
test(!p2 && !p3);

if (initial->supportsNullOptional())
{
p2 = initial->opOneOptional(OneOptionalPtr(), p3);
test(*p2 == nullptr && *p3 == nullptr);
}
OneOptionalPtr p1 = make_shared<OneOptional>();
OneOptionalPtr p3;
OneOptionalPtr p2 = initial->opOneOptional(p1, p3);
test(!p2->a && !p3->a);

p1 = make_shared<OneOptional>(58);
p2 = initial->opOneOptional(p1, p3);
test((*p2)->a == 58 && (*p3)->a == 58);
test(p2->a == 58 && p3->a == 58);

Ice::OutputStream out(communicator);
out.startEncapsulation();
out.write(2, p1);
out.write(p1);
out.endEncapsulation();
out.finished(inEncaps);
initial->ice_invoke("opOneOptional", Ice::OperationMode::Normal, inEncaps, outEncaps);
Ice::InputStream in(communicator, out.getEncoding(), outEncaps);
in.startEncapsulation();
in.read(1, p2);
in.read(3, p3);
in.read(p2);
in.read(p3);
in.endEncapsulation();
test((*p2)->a == 58 && (*p3)->a == 58);

Ice::InputStream in2(communicator, out.getEncoding(), outEncaps);
in2.startEncapsulation();
in2.endEncapsulation();
test(p2->a == 58 && p3->a == 58);
}

{
Expand Down Expand Up @@ -1668,59 +1657,52 @@ allTests(Test::TestHelper* helper, bool)
{
try
{
initial->opOptionalException(nullopt, nullopt, nullopt);
initial->opOptionalException(nullopt, nullopt);
test(false);
}
catch (const OptionalException& ex)
{
test(!ex.a);
test(!ex.b);
test(!ex.o);
}

try
{
initial->opOptionalException(30, string("test"), make_shared<OneOptional>(53));
initial->opOptionalException(30, string("test"));
test(false);
}
catch (const OptionalException& ex)
{
test(ex.a == 30);
test(ex.b == string("test"));
test((*ex.o)->a = 53);
}

try
{
//
// Use the 1.0 encoding with an exception whose only class members are optional.
// Use the 1.0 encoding with an exception whose only data members are optional.
//
initial->ice_encodingVersion(Ice::Encoding_1_0)
->opOptionalException(30, string("test"), make_shared<OneOptional>(53));
initial->ice_encodingVersion(Ice::Encoding_1_0)->opOptionalException(30, string("test"));
test(false);
}
catch (const OptionalException& ex)
{
test(!ex.a);
test(!ex.b);
test(!ex.o);
}

try
{
optional<int32_t> a;
optional<string> b;
optional<OneOptionalPtr> o;
initial->opDerivedException(a, b, o);
initial->opDerivedException(a, b);
test(false);
}
catch (const DerivedException& ex)
{
test(!ex.a);
test(!ex.b);
test(!ex.o);
test(!ex.ss);
test(!ex.o2);
test(ex.d1 == "d1");
test(ex.d2 == "d2");
}
Expand All @@ -1733,17 +1715,14 @@ allTests(Test::TestHelper* helper, bool)
{
optional<int32_t> a = 30;
optional<string> b = string("test2");
optional<OneOptionalPtr> o = make_shared<OneOptional>(53);
initial->opDerivedException(a, b, o);
initial->opDerivedException(a, b);
test(false);
}
catch (const DerivedException& ex)
{
test(ex.a == 30);
test(ex.b == string("test2"));
test((*ex.o)->a == 53);
test(ex.ss == string("test2"));
test((*ex.o2)->a == 53);
test(ex.d1 == "d1");
test(ex.d2 == "d2");
}
Expand All @@ -1756,17 +1735,14 @@ allTests(Test::TestHelper* helper, bool)
{
optional<int32_t> a;
optional<string> b;
optional<OneOptionalPtr> o;
initial->opRequiredException(a, b, o);
initial->opRequiredException(a, b);
test(false);
}
catch (const RequiredException& ex)
{
test(!ex.a);
test(!ex.b);
test(!ex.o);
test(ex.ss == string("test"));
test(!ex.o2);
}
catch (const OptionalException&)
{
Expand All @@ -1777,17 +1753,14 @@ allTests(Test::TestHelper* helper, bool)
{
optional<int32_t> a = 30;
optional<string> b = string("test2");
optional<OneOptionalPtr> o = make_shared<OneOptional>(53);
initial->opRequiredException(a, b, o);
initial->opRequiredException(a, b);
test(false);
}
catch (const RequiredException& ex)
{
test(ex.a == 30);
test(ex.b == string("test2"));
test((*ex.o)->a == 53);
test(ex.ss == string("test2"));
test(ex.o2->a == 53);
}
catch (const OptionalException&)
{
Expand All @@ -1801,7 +1774,6 @@ allTests(Test::TestHelper* helper, bool)
test(initial->opMStruct1());
test(initial->opMDict1());
test(initial->opMSeq1());
test(initial->opMG1());

{
optional<Test::SmallStruct> p1, p2, p3;
Expand Down Expand Up @@ -1834,15 +1806,6 @@ allTests(Test::TestHelper* helper, bool)
p3 = initial->opMDict2(p1, p2);
test(p2 == p1 && p3 == p1);
}
{
optional<Test::GPtr> p1, p2, p3;
p3 = initial->opMG2(nullopt, p2);
test(!p2 && !p3);

p1 = make_shared<Test::G>();
p3 = initial->opMG2(p1, p2);
test(p2 && p3 && *p3 == *p2);
}
}
cout << "ok" << endl;
return initial;
Expand Down
23 changes: 5 additions & 18 deletions cpp/test/Ice/optional/Test.ice
Original file line number Diff line number Diff line change
Expand Up @@ -136,21 +136,18 @@ exception OptionalException
bool req = false;
optional(1) int a = 5;
optional(2) string b;
optional(50) OneOptional o;
}

exception DerivedException extends OptionalException
{
string d1;
optional(600) string ss = "test";
optional(601) OneOptional o2;
string d2;
}

exception RequiredException extends OptionalException
{
string ss = "test";
OneOptional o2;
}

class OptionalWithCustom
Expand Down Expand Up @@ -193,13 +190,13 @@ interface Initial

["marshaled-result"] Object pingPong(Object o);

void opOptionalException(optional(1) int a, optional(2) string b, optional(3) OneOptional o)
void opOptionalException(optional(1) int a, optional(2) string b)
throws OptionalException;

void opDerivedException(optional(1) int a, optional(2) string b, optional(3) OneOptional o)
void opDerivedException(optional(1) int a, optional(2) string b)
throws OptionalException;

void opRequiredException(optional(1) int a, optional(2) string b, optional(3) OneOptional o)
void opRequiredException(optional(1) int a, optional(2) string b)
throws OptionalException;

optional(1) byte opByte(optional(2) byte p1, out optional(3) byte p3);
Expand All @@ -226,10 +223,10 @@ interface Initial

optional(1) VarStruct opVarStruct(optional(2) VarStruct p1, out optional(3) VarStruct p3);

optional(1) OneOptional opOneOptional(optional(2) OneOptional p1, out optional(3) OneOptional p3);

optional(1) MyInterface* opMyInterfaceProxy(optional(2) MyInterface* p1, out optional(3) MyInterface* p3);

OneOptional opOneOptional(OneOptional p1, out OneOptional p3);

// Custom mapping operations
["cpp:array"] optional(1) ByteSeq opByteSeq(["cpp:array"] optional(2) ByteSeq p1,
out ["cpp:array"] optional(3) ByteSeq p3);
Expand Down Expand Up @@ -294,21 +291,11 @@ interface Initial
["marshaled-result"] optional(1) StringIntDict opMDict2(optional(2) StringIntDict p1,
out optional(3) StringIntDict p2);

["marshaled-result"] optional(1) G opMG1();
["marshaled-result"] optional(1) G opMG2(optional(2) G p1, out optional(3) G p2);

bool supportsRequiredParams();

bool supportsJavaSerializable();

bool supportsCsharpSerializable();

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should also remove supportsCsharpSerialize above. We dropped support for C# serialization a while ago.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and supportsRequiredParams. I can't find any call to this operation.

Copy link
Member Author

@InsertCreativityHere InsertCreativityHere May 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is only used by the Java mapping.
Java is the only language which returns true for this, and it's also the only language that calls it.
At the top of Ice/Optional/AllTests.java

That's part of the Java cleanup I mentioned in the top description.

// TODO: remove.
// This test actually uses this flag only for tagged classes (to be removed), not tagged proxies.
// For tagged proxies: in IceRPC and from Ice 3.8 on, we don't distinguish between a not-set tagged
// proxy and a tagged proxy set to nullopt. We encode as not-set in both cases, and decode successfully both to
// nulltopt.
bool supportsNullOptional();
}

}
19 changes: 5 additions & 14 deletions cpp/test/Ice/optional/TestAMD.ice
Original file line number Diff line number Diff line change
Expand Up @@ -136,21 +136,18 @@ exception OptionalException
bool req = false;
optional(1) int a = 5;
optional(2) string b;
optional(50) OneOptional o;
}

exception DerivedException extends OptionalException
{
string d1;
optional(600) string ss = "test";
optional(601) OneOptional o2;
string d2;
}

exception RequiredException extends OptionalException
{
string ss = "test";
OneOptional o2;
}

class OptionalWithCustom
Expand Down Expand Up @@ -194,13 +191,13 @@ interface Initial

Object pingPong(Object o);

void opOptionalException(optional(1) int a, optional(2) string b, optional(3) OneOptional o)
void opOptionalException(optional(1) int a, optional(2) string b)
throws OptionalException;

void opDerivedException(optional(1) int a, optional(2) string b, optional(3) OneOptional o)
void opDerivedException(optional(1) int a, optional(2) string b)
throws OptionalException;

void opRequiredException(optional(1) int a, optional(2) string b, optional(3) OneOptional o)
void opRequiredException(optional(1) int a, optional(2) string b)
throws OptionalException;

optional(1) byte opByte(optional(2) byte p1, out optional(3) byte p3);
Expand All @@ -227,10 +224,10 @@ interface Initial

optional(1) VarStruct opVarStruct(optional(2) VarStruct p1, out optional(3) VarStruct p3);

optional(1) OneOptional opOneOptional(optional(2) OneOptional p1, out optional(3) OneOptional p3);

optional(1) MyInterface* opMyInterfaceProxy(optional(2) MyInterface* p1, out optional(3) MyInterface* p3);

OneOptional opOneOptional(OneOptional p1, out OneOptional p3);

// Custom mapping operations
["cpp:array"] optional(1) ByteSeq opByteSeq(["cpp:array"] optional(2) ByteSeq p1,
out ["cpp:array"] optional(3) ByteSeq p3);
Expand Down Expand Up @@ -294,17 +291,11 @@ interface Initial
["marshaled-result"] optional(1) StringIntDict opMDict2(optional(2) StringIntDict p1,
out optional(3) StringIntDict p2);

["marshaled-result"] optional(1) G opMG1();
["marshaled-result"] optional(1) G opMG2(optional(2) G p1, out optional(3) G p2);

bool supportsRequiredParams();

bool supportsJavaSerializable();

bool supportsCsharpSerializable();

// TODO: remove. See Test.ice comment.
bool supportsNullOptional();
}

}
Loading