-
Notifications
You must be signed in to change notification settings - Fork 3
/
test.cpp
46 lines (45 loc) · 1.44 KB
/
test.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <util/Platform.hpp>
#include "output.pbj.hpp"
using namespace Sirikata;
using namespace Sirikata::PB;
int main (int argc, char**argv) {
TestMessage tm;
tm.set_xxfr(1.25);
tm.set_v3f(PBJ::Vector3f(1,2,3));
tm.add_submessers().set_subvector(PBJ::Vector3d(2,3,4));
tm.mutable_submes().set_subvector(PBJ::Vector3d(5,6,7));
tm.mutable_extmesser().mutable_sub_mes().set_subvector(PBJ::Vector3d(8,9,10));
std::string s;
bool retval=tm.SerializeToString(&s);
assert(retval);
std::cout<<s.length();
TestMessage ti;
retval=ti.ParseFromString(s);
assert(retval);
assert(ti.v3f().x==1);
assert(ti.v3f().y==2);
assert(ti.v3f().z==3);
assert(ti.xxfr()==1.25);
assert(ti.submessers(0).subvector().x==2);
assert(ti.submessers(0).subvector().y==3);
assert(ti.submessers(0).subvector().z==4);
assert(ti.submes().subvector().x==5);
assert(ti.submes().subvector().y==6);
assert(ti.submes().subvector().z==7);
assert(ti.extmesser().sub_mes().subvector().x==8);
assert(ti.extmesser().sub_mes().subvector().y==9);
assert(ti.extmesser().sub_mes().subvector().z==10);
/*
Content c;
ITimedVector xtv = c.mutable_c().mutable_vec();
xtv.set_p(Sirikata::Vector3f(1,2,3));
xtv.set_t(Sirikata::Time::epoch());
std::string cstr;
c.SerializeToString(&cstr);
Content cc;
cc.ParseFromString(cstr);
Stuff ss=cc.c();
TimedVector itv=ss.vec();
*/
return 0;
}