Protocol Buffers - Google's data interchange format (grpc依赖)
https://developers.google.com/protocol-buffers/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
1.0 KiB
39 lines
1.0 KiB
12 years ago
|
/*
|
||
|
* upb - a minimalist implementation of protocol buffers.
|
||
|
*
|
||
|
* Copyright (c) 2011 Google Inc. See LICENSE for details.
|
||
|
*
|
||
|
*/
|
||
|
|
||
|
#include "upb/handlers.h"
|
||
|
#include "upb/descriptor/descriptor.upb.h"
|
||
|
#include "upb_test.h"
|
||
|
#include <stdlib.h>
|
||
|
#include <string.h>
|
||
|
|
||
|
static bool startmsg(void *c, const void *hd) { return true; }
|
||
|
|
||
|
static void test_error() {
|
||
|
upb_handlers *h = upb_handlers_new(GOOGLE_PROTOBUF_DESCRIPTORPROTO, NULL, &h);
|
||
|
|
||
|
// Attempt to set the same handler twice causes error.
|
||
|
ASSERT(upb_ok(upb_handlers_status(h)));
|
||
|
upb_handlers_setstartmsg(h, &startmsg, NULL, NULL);
|
||
|
ASSERT(upb_ok(upb_handlers_status(h)));
|
||
|
upb_handlers_setstartmsg(h, &startmsg, NULL, NULL);
|
||
|
ASSERT(!upb_ok(upb_handlers_status(h)));
|
||
|
ASSERT(!upb_handlers_freeze(&h, 1, NULL));
|
||
|
|
||
|
// Clearing the error will let us proceed.
|
||
|
upb_handlers_clearerr(h);
|
||
|
ASSERT(upb_handlers_freeze(&h, 1, NULL));
|
||
|
ASSERT(upb_handlers_isfrozen(h));
|
||
|
|
||
|
upb_handlers_unref(h, &h);
|
||
|
}
|
||
|
|
||
|
int run_tests(int argc, char *argv[]) {
|
||
|
test_error();
|
||
|
return 0;
|
||
|
}
|