当前位置: 首页>>代码示例>>C++>>正文


C++ StringUnMarshaller::unmarshal方法代码示例

本文整理汇总了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);
  }
开发者ID:FunkyFortune,项目名称:rubinius,代码行数:7,代码来源:test_unmarshal.hpp

示例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);
  }
开发者ID:FunkyFortune,项目名称:rubinius,代码行数:7,代码来源:test_unmarshal.hpp

示例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);
  }
开发者ID:FunkyFortune,项目名称:rubinius,代码行数:7,代码来源:test_unmarshal.hpp

示例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"))));
  }
开发者ID:FunkyFortune,项目名称:rubinius,代码行数:26,代码来源:test_unmarshal.hpp

示例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"));
  }
开发者ID:FunkyFortune,项目名称:rubinius,代码行数:7,代码来源:test_unmarshal.hpp

示例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"));
  }
开发者ID:marnen,项目名称:rubinius,代码行数:8,代码来源:test_unmarshal.hpp

示例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");
  }
开发者ID:FunkyFortune,项目名称:rubinius,代码行数:8,代码来源:test_unmarshal.hpp

示例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);
  }
开发者ID:marnen,项目名称:rubinius,代码行数:11,代码来源:test_unmarshal.hpp

示例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));
  }
开发者ID:FunkyFortune,项目名称:rubinius,代码行数:11,代码来源:test_unmarshal.hpp

示例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));
  }
开发者ID:FunkyFortune,项目名称:rubinius,代码行数:11,代码来源:test_unmarshal.hpp

示例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));
  }
开发者ID:FunkyFortune,项目名称:rubinius,代码行数:12,代码来源:test_unmarshal.hpp

示例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());
  }
开发者ID:marnen,项目名称:rubinius,代码行数:14,代码来源:test_unmarshal.hpp

示例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);
  }
开发者ID:FunkyFortune,项目名称:rubinius,代码行数:23,代码来源:test_unmarshal.hpp

示例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));
  }
开发者ID:FunkyFortune,项目名称:rubinius,代码行数:15,代码来源:test_unmarshal.hpp

示例15: test_false

  void test_false() {
    mar->sstream.str(std::string("f\n"));
    Object* obj = mar->unmarshal();

    TS_ASSERT_EQUALS(obj, Qfalse);
  }
开发者ID:FunkyFortune,项目名称:rubinius,代码行数:6,代码来源:test_unmarshal.hpp


注:本文中的StringUnMarshaller::unmarshal方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。