本文整理汇总了C++中StringUnMarshaller::unmarshal方法的典型用法代码示例。如果您正苦于以下问题:C++ StringUnMarshaller::unmarshal方法的具体用法?C++ StringUnMarshaller::unmarshal怎么用?C++ StringUnMarshaller::unmarshal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringUnMarshaller
的用法示例。
在下文中一共展示了StringUnMarshaller::unmarshal方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_large_int
void test_large_int() {
mar->sstream.str(std::string("I\n100000000\n"));
Object* obj = mar->unmarshal();
TS_ASSERT(kind_of<Integer>(obj));
TS_ASSERT_EQUALS(as<Integer>(obj)->to_ulong_long(), 4294967296ULL);
}
示例2: test_int
void test_int() {
mar->sstream.str(std::string("I\n42\n"));
Object* obj = mar->unmarshal();
TS_ASSERT(obj->fixnum_p());
TS_ASSERT_EQUALS(as<Integer>(obj)->to_native(), 66);
}
示例3: test_larger_int
void test_larger_int() {
mar->sstream.str(std::string("I\n9d89d89d89d89dc\n"));
Object* obj = mar->unmarshal();
TS_ASSERT(kind_of<Integer>(obj));
TS_ASSERT_EQUALS(as<Integer>(obj)->to_ulong_long(), 709490156681136604ULL);
}
示例4: test_cmethod
void test_cmethod() {
std::string str = "M\n1\nn\nx\n12\nobject_equal\nx\n4\ntest\ni\n1\n0\nI\na\nI\n0\nI\n0\nI\n0\nn\np\n2\nI\n1\nI\n2\np\n1\np\n3\nI\n0\nI\n1\nI\n1\nx\n8\nnot_real\np\n1\nx\n4\nblah\n";
mar->sstream.str(str);
Object* obj = mar->unmarshal();
TS_ASSERT(kind_of<CompiledMethod>(obj));
CompiledMethod* cm = as<CompiledMethod>(obj);
TS_ASSERT_EQUALS(cm->ivars(), Qnil);
TS_ASSERT_EQUALS(cm->primitive(), state->symbol("object_equal"));
TS_ASSERT_EQUALS(cm->name(), state->symbol("test"));
TS_ASSERT(tuple_equals(cm->iseq()->opcodes(), Tuple::from(state, 1, Fixnum::from(0))));
TS_ASSERT_EQUALS(cm->stack_size(), Fixnum::from(10));
TS_ASSERT_EQUALS(cm->local_count(), Fixnum::from(0));
TS_ASSERT_EQUALS(cm->required_args(), Fixnum::from(0));
TS_ASSERT_EQUALS(cm->total_args(), Fixnum::from(0));
TS_ASSERT_EQUALS(cm->splat(), Qnil);
TS_ASSERT(tuple_equals(cm->literals(), Tuple::from(state, 2, Fixnum::from(1), Fixnum::from(2))));
TS_ASSERT(tuple_equals(cm->lines(), Tuple::from(state, 1,
Tuple::from(state, 3, Fixnum::from(0), Fixnum::from(1), Fixnum::from(1)))));
TS_ASSERT_EQUALS(cm->file(), state->symbol("not_real"));
TS_ASSERT(tuple_equals(cm->local_names(), Tuple::from(state, 1, state->symbol("blah"))));
}
示例5: test_symbol
void test_symbol() {
mar->sstream.str(std::string("x\n4\nblah\n"));
Object* obj = mar->unmarshal();
TS_ASSERT(obj->symbol_p());
TS_ASSERT_EQUALS(obj, state->symbol("blah"));
}
示例6: test_sendsite
void test_sendsite() {
mar->sstream.str(std::string("S\n4\nblah\n"));
Object* obj = mar->unmarshal();
TS_ASSERT(kind_of<SendSite>(obj));
TS_ASSERT_EQUALS(as<SendSite>(obj)->name(), state->symbol("blah"));
}
示例7: test_string
void test_string() {
mar->sstream.str(std::string("s\n4\nblah\n"));
Object* obj = mar->unmarshal();
TS_ASSERT(kind_of<String>(obj));
String *str = as<String>(obj);
TS_ASSERT_EQUALS(std::string(str->c_str()), "blah");
}
示例8: test_float
void test_float() {
mar->sstream.str(std::string("d\n15.5\n"));
Object* obj = mar->unmarshal();
TS_ASSERT(kind_of<Float>(obj));
Float* flt = as<Float>(obj);
TS_ASSERT_EQUALS(flt->val, 15.5);
}
示例9: test_float_infinity
void test_float_infinity() {
mar->sstream.str(std::string("d\nInfinity\n"));
Object* obj = mar->unmarshal();
TS_ASSERT(kind_of<Float>(obj));
Float* flt = as<Float>(obj);
TS_ASSERT(std::isinf(flt->val));
}
示例10: test_float_nan
void test_float_nan() {
mar->sstream.str(std::string("d\nNaN\n"));
Object* obj = mar->unmarshal();
TS_ASSERT(kind_of<Float>(obj));
Float* flt = as<Float>(obj);
TS_ASSERT(std::isnan(flt->val));
}
示例11: test_tuple
void test_tuple() {
mar->sstream.str(std::string("p\n2\nI\n2\nI\n2f\n"));
Object* obj = mar->unmarshal();
TS_ASSERT(kind_of<Tuple>(obj));
Tuple* tup = as<Tuple>(obj);
TS_ASSERT_EQUALS(tup->at(state, 0), Fixnum::from(2));
TS_ASSERT_EQUALS(tup->at(state, 1), Fixnum::from(47));
}
示例12: test_array
void test_array() {
mar->sstream.str(std::string("A\n3\nI\n1\nx\n3\nfoo\ns\n4\nblah\n"));
Object* obj = mar->unmarshal();
TS_ASSERT(kind_of<Array>(obj));
Array* ary = as<Array>(obj);
TS_ASSERT_EQUALS(ary->get(state, 0), Fixnum::from(1));
TS_ASSERT_EQUALS(ary->get(state, 1), state->symbol("foo"));
String* str = as<String>(ary->get(state, 2));
TS_ASSERT_EQUALS(std::string("blah"), str->byte_address());
}
示例13: test_float
void test_float() {
mar->sstream.str(
std::string("d\n +0.666666666666666629659232512494781985878944396972656250 -2\n"));
Object* obj = mar->unmarshal();
TS_ASSERT(kind_of<Float>(obj));
Float* flt = as<Float>(obj);
TS_ASSERT_EQUALS(flt->val, 1.0 / 6.0);
mar->sstream.str(
std::string("d\n +0.999999999999999888977697537484345957636833190917968750 1024\n"));
obj = mar->unmarshal();
TS_ASSERT(kind_of<Float>(obj));
flt = as<Float>(obj);
double diff = flt->val - DBL_MAX;
TS_ASSERT(diff < 0.00000001 && diff > - 0.00000001);
}
示例14: test_iseq
void test_iseq() {
mar->sstream.str(std::string("i\n1\n0\n"));
Object* obj = mar->unmarshal();
TS_ASSERT(kind_of<InstructionSequence>(obj));
InstructionSequence* seq = as<InstructionSequence>(obj);
TS_ASSERT(kind_of<Tuple>(seq->opcodes()));
TS_ASSERT_EQUALS(seq->opcodes()->num_fields(), 1);
TS_ASSERT_EQUALS(seq->opcodes()->at(state, 0), Fixnum::from(0));
}
示例15: test_false
void test_false() {
mar->sstream.str(std::string("f\n"));
Object* obj = mar->unmarshal();
TS_ASSERT_EQUALS(obj, Qfalse);
}