Comment #1 on issue 678 by [email protected]: Clearing an extension
message clears it but HasExtension still reports it's not cleared (Protobuf
2.4.1)
https://code.google.com/p/protobuf/issues/detail?id=678
For the sake of completeness, here are the files contained in the ZIP:
$ cat A.proto
message A {
optional string a = 1;
extensions 100 to 1000;
}
message AExt {
message E {
optional string e = 1;
}
extend A {
repeated E ext = 100;
}
}
$ cat main.cc
// $ protoc --version
// libprotoc 2.4.1
// $ c++ -L/opt/brew/lib -I/opt/brew/include/ main.cc A.pb.cc -lprotobuf -o
main
// $ c++ --version
// Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
// Target: x86_64-apple-darwin13.4.0
// Thread model: posix
#include "A.pb.h"
#include <iostream>
#include <google/protobuf/text_format.h>
void expectTrue(bool e, const std::string& msg) {
if (!e) {
std::cout << "violated: " << msg << std::endl;
}
}
int main() {
std::cout << "hello" << std::endl;
// Clearing a message extension clears it but reports as still present
{
A a;
a.AddExtension(AExt::ext)->set_e("e");
expectTrue(a.HasExtension(AExt::ext), "A has extension");
expectTrue(a.ExtensionSize(AExt::ext) == 1, "A's extension has size
1");
a.ClearExtension(AExt::ext);
expectTrue(a.ExtensionSize(AExt::ext) == 0, "A's extension has size
0");
expectTrue(!a.HasExtension(AExt::ext), "A has no extension");
// FAILS
}
return 0;
}
--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings
--
You received this message because you are subscribed to the Google Groups "Protocol
Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.