• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ ref函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中ref函数的典型用法代码示例。如果您正苦于以下问题:C++ ref函数的具体用法?C++ ref怎么用?C++ ref使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了ref函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: assert

/* V_STRING -> V_LENS */
static struct value *lns_seq(struct info *info, struct value *str) {
    assert(str->tag == V_STRING);
    return lns_make_prim(L_SEQ, ref(info), NULL, ref(str->string));
}
开发者ID:turingmachine,项目名称:augeas,代码行数:5,代码来源:builtin.c


示例2: setRef

	inline void setRef(Instance* instance) const {
		ref() = instance;
	}
开发者ID:corelon,项目名称:paco,代码行数:3,代码来源:Variant.hpp


示例3: ref

Transformer::Transformer() {
    identity_ = true;
    mat00 = mat11 = 1;
    mat01 = mat10 = mat20 = mat21 = 0;
    ref();
}
开发者ID:neurodebian,项目名称:iv-hines,代码行数:6,代码来源:transformer.cpp


示例4: ref

void MediaElementAudioSourceNode::lock()
{
    ref();
    m_processLock.lock();
}
开发者ID:jeremyroman,项目名称:blink,代码行数:5,代码来源:MediaElementAudioSourceNode.cpp


示例5: HHVM_FUNCTION

Variant HHVM_FUNCTION(eregi, const String& pattern, const String& str,
                             VRefParam regs /* = null */) {
  return HHVM_FN(mb_eregi)(pattern, str, ref(regs));
}
开发者ID:DieterLutz,项目名称:hhvm,代码行数:4,代码来源:ext_pcre.cpp


示例6: f_preg_match_all

bool TestExtPreg::test_preg_match_all() {
  Variant matches;

  f_preg_match_all("/\\(?  (\\d{3})?  \\)?  (?(1)  [\\-\\s] ) \\d{3}-\\d{4}/x",
                   "Call 555-1212 or 1-800-555-1212", ref(matches));
  VS(f_print_r(matches, true),
     "Array\n"
     "(\n"
     "    [0] => Array\n"
     "        (\n"
     "            [0] => 555-1212\n"
     "            [1] => 800-555-1212\n"
     "        )\n"
     "\n"
     "    [1] => Array\n"
     "        (\n"
     "            [0] => \n"
     "            [1] => 800\n"
     "        )\n"
     "\n"
     ")\n");

  // The \\2 is an example of backreferencing. This tells pcre that
  // it must match the second set of parentheses in the regular expression
  // itself, which would be the ([\w]+) in this case. The extra backslash is
  // required because the string is in double quotes.
  String html = "<b>bold text</b><a href=howdy.html>click me</a>";
  f_preg_match_all("/(<([\\w]+)[^>]*>)(.*)(<\\/\\2>)/", html, ref(matches),
                   k_PREG_SET_ORDER);
  VS(f_print_r(matches, true),
     "Array\n"
     "(\n"
     "    [0] => Array\n"
     "        (\n"
     "            [0] => <b>bold text</b>\n"
     "            [1] => <b>\n"
     "            [2] => b\n"
     "            [3] => bold text\n"
     "            [4] => </b>\n"
     "        )\n"
     "\n"
     "    [1] => Array\n"
     "        (\n"
     "            [0] => <a href=howdy.html>click me</a>\n"
     "            [1] => <a href=howdy.html>\n"
     "            [2] => a\n"
     "            [3] => click me\n"
     "            [4] => </a>\n"
     "        )\n"
     "\n"
     ")\n");

  String str = "a: 1\nb: 2\nc: 3\n";
  f_preg_match_all("/(?<name>\\w+): (?<digit>\\d+)/", str, ref(matches));
  VS(f_print_r(matches, true),
     "Array\n"
     "(\n"
     "    [0] => Array\n"
     "        (\n"
     "            [0] => a: 1\n"
     "            [1] => b: 2\n"
     "            [2] => c: 3\n"
     "        )\n"
     "\n"
     "    [name] => Array\n"
     "        (\n"
     "            [0] => a\n"
     "            [1] => b\n"
     "            [2] => c\n"
     "        )\n"
     "\n"
     "    [1] => Array\n"
     "        (\n"
     "            [0] => a\n"
     "            [1] => b\n"
     "            [2] => c\n"
     "        )\n"
     "\n"
     "    [digit] => Array\n"
     "        (\n"
     "            [0] => 1\n"
     "            [1] => 2\n"
     "            [2] => 3\n"
     "        )\n"
     "\n"
     "    [2] => Array\n"
     "        (\n"
     "            [0] => 1\n"
     "            [1] => 2\n"
     "            [2] => 3\n"
     "        )\n"
     "\n"
     ")\n");

  return Count(true);
}
开发者ID:CyaLiven,项目名称:hiphop-php,代码行数:96,代码来源:test_ext_preg.cpp


示例7: f_collator_sort

Variant f_collator_sort(CVarRef obj, VRefParam arr,
                        int64 sort_flag /* = q_Collator$$SORT_REGULAR */) {
  CHECK_COLL(obj);
  return coll->t_sort(ref(arr), sort_flag);
}
开发者ID:cctech,项目名称:hiphop-php,代码行数:5,代码来源:ext_intl.cpp


示例8: f_getmxrr

bool f_getmxrr(const String& hostname, VRefParam mxhosts,
               VRefParam weight /* = uninit_null() */) {
  return f_dns_get_mx(hostname, ref(mxhosts), weight);
}
开发者ID:Alienfeel,项目名称:hhvm,代码行数:4,代码来源:ext_network.cpp


示例9: sendout

void smthread_scanner_t::scan_i_scan(const stid_t& fid, int num_recs,
                ss_m::concurrency_t cc)
{
    outstream << "********** Starting scanning file " << fid  
        << " expecting " << num_recs << " records" 
        << endl;
    sendout();

    scan_file_i scan(fid, cc);

    w_rc_t rc = scan.error_code();
    if(rc.is_error()) {
        cerr << "Could not create scan_i with fid " << fid 
            << " error is " << rc
            << endl;
        ::exit(1);
    }
    pin_i         *handle;
    bool        eof = false;
    int         i = START;
    do {
        w_rc_t rc;
        rc = scan.error_code();
        if(rc.is_error()) {
            cerr << "Could not create scan_i with fid " << fid 
                << " error is " << rc
                << endl;
            ::exit(1);
        }
        w_assert1(scan.error_code().is_error() == false);

        rc = scan.next(handle, 0, eof);
        if(rc.is_error()) {
            W_COERCE(rc);
        }

        if(debug) {
            outstream << " scanned i " << i << ": "  
                << scan.curr_rid 
                << " eof=" << eof
                << endl;
            sendout();
        }

        if(eof) break;

        w_assert1(handle->pinned());
        const char *hdr =handle->hdr();
        smsize_t hdrsize=handle->hdr_size();
        /// alignment should be ok:
        vec_t ref(hdr, hdrsize);
        int refi;
        ref.copy_to(&refi, sizeof (refi));

        const char *datum =handle->body();
        smsize_t datasize=handle->body_size();

        outstream << handle->rid();
        outstream << "    header " 
            << refi ;
        
        if(append_only) {
            w_assert1(refi == i);
            // if we used append-only on the file creation,
            // we had better find the order preserved.
            outstream << "; data (size " 
            << datasize 
            << ") " << datum ;
            outstream << " A:OK " << endl;
        } else {
            rid_t r;
            memcpy(&r, datum, sizeof(r));
            w_assert1(r == handle->rid());
            outstream << "; data (size " 
            << datasize 
            << ") " << r ;
            outstream << " rid:OK " << endl;
        }
        sendout();

/*
        const char *body =handle->body();
        smsize_t bodysize=handle->body_size();
*/
        i++;
    } while (1) ;
    if(num_recs == i-1) {
        if(debug) {
            outstream << "scan_i scan complete, OK" << endl;
            sendout();
        }
    } else {
        outstream << "ERROR IN COUNT: scan_i scan complete, i="  << i-1
        << " num_rec expected =" << num_recs
        << endl;
        sendout();
    }

    assert(i-START == num_recs);
}
开发者ID:glycerine,项目名称:shore-mt,代码行数:100,代码来源:file_scan_many.cpp


示例10: ref

std::pair<int, int> Puzzle::get(int row, int column) const
{
    int value = ref(row, column)-1;
    return { value / d_columns, value % d_columns };
}
开发者ID:kjohns19,项目名称:15puzzle,代码行数:5,代码来源:puzzle.cpp


示例11: main

int
main ()
{
  struct ss  ss;
  struct ss  ssa[2];
  struct arraystruct arraystruct;
  string x = make_string ("this is x");
  zzz_type c = make_container ("container");
  zzz_type c2 = make_container ("container2");
  const struct string_repr cstring = { { "const string" } };
  /* Clearing by being `static' could invoke an other GDB C++ bug.  */
  struct nullstr nullstr;
  nostring_type nstype, nstype2;
  struct memory_error me;
  struct ns ns, ns2;
  struct lazystring estring, estring2;
  struct hint_error hint_error;
  struct children_as_list children_as_list;

  nstype.elements = narray;
  nstype.len = 0;

  me.s = "blah";

  init_ss(&ss, 1, 2);
  init_ss(ssa+0, 3, 4);
  init_ss(ssa+1, 5, 6);
  memset (&nullstr, 0, sizeof nullstr);

  arraystruct.y = 7;
  init_s (&arraystruct.x[0], 23);
  init_s (&arraystruct.x[1], 24);

  ns.null_str = "embedded\0null\0string";
  ns.length = 20;

  /* Make a "corrupted" string.  */
  ns2.null_str = NULL;
  ns2.length = 20;

  estring.lazy_str = "embedded x\201\202\203\204" ;

  /* Incomplete UTF-8, but ok Latin-1.  */
  estring2.lazy_str = "embedded x\302";

#ifdef __cplusplus
  S cps;

  cps.zs = 7;
  init_s(&cps, 8);

  SS cpss;
  cpss.zss = 9;
  init_s(&cpss.s, 10);

  SS cpssa[2];
  cpssa[0].zss = 11;
  init_s(&cpssa[0].s, 12);
  cpssa[1].zss = 13;
  init_s(&cpssa[1].s, 14);

  SSS sss(15, cps);

  SSS& ref (sss);

  Derived derived;
  
  Fake fake (42);
#endif

  add_item (&c, 23);		/* MI breakpoint here */
  add_item (&c, 72);

#ifdef MI
  add_item (&c, 1011);
  c.elements[0] = 1023;
  c.elements[0] = 2323;

  add_item (&c2, 2222);
  add_item (&c2, 3333);

  substruct_test ();
  do_nothing ();
#endif

  nstype.elements[0] = 7;
  nstype.elements[1] = 42;
  nstype.len = 2;
  
  nstype2 = nstype;

  eval_sub ();

  bug_14741();      /* break to inspect struct and union */
  return 0;
}
开发者ID:Drakey83,项目名称:steamlink-sdk,代码行数:96,代码来源:scm-pretty-print.c


示例12: f_stream_select

Variant f_stream_select(VRefParam read, VRefParam write, VRefParam except,
                        CVarRef vtv_sec, int tv_usec /* = 0 */) {
  return f_socket_select(ref(read), ref(write), ref(except), vtv_sec, tv_usec);
}
开发者ID:Attnaorg,项目名称:hhvm,代码行数:4,代码来源:ext_stream.cpp


示例13: updateTargetsOk

    Status WriteOp::targetWrites( const NSTargeter& targeter,
                                  std::vector<TargetedWrite*>* targetedWrites ) {

        bool isUpdate = _itemRef.getOpType() == BatchedCommandRequest::BatchType_Update;
        bool isDelete = _itemRef.getOpType() == BatchedCommandRequest::BatchType_Delete;

        // In case of error, don't leak.
        OwnedPointerVector<ShardEndpoint> endpointsOwned;
        vector<ShardEndpoint*>& endpoints = endpointsOwned.mutableVector();

        if ( isUpdate || isDelete ) {

            // Updates/deletes targeted by query

            BSONObj queryDoc =
                isUpdate ? _itemRef.getUpdate()->getQuery() : _itemRef.getDelete()->getQuery();

            Status targetStatus = targeter.targetQuery( queryDoc, &endpoints );

            if ( targetStatus.isOK() ) {
                targetStatus =
                    isUpdate ?
                        updateTargetsOk( *this, endpoints ) : deleteTargetsOk( *this, endpoints );
            }

            if ( !targetStatus.isOK() ) return targetStatus;
        }
        else {
            dassert( _itemRef.getOpType() == BatchedCommandRequest::BatchType_Insert );

            // Inserts targeted by doc itself

            ShardEndpoint* endpoint = NULL;
            Status targetStatus = targeter.targetDoc( _itemRef.getDocument(), &endpoint );

            if ( !targetStatus.isOK() ) {
                dassert( NULL == endpoint );
                return targetStatus;
            }

            dassert( NULL != endpoint );
            endpoints.push_back( endpoint );
        }

        for ( vector<ShardEndpoint*>::iterator it = endpoints.begin(); it != endpoints.end();
            ++it ) {

            ShardEndpoint* endpoint = *it;

            _childOps.push_back( new ChildWriteOp( this ) );

            WriteOpRef ref( _itemRef.getItemIndex(), _childOps.size() - 1 );

            // For now, multiple endpoints imply no versioning
            if ( endpoints.size() == 1u ) {
                targetedWrites->push_back( new TargetedWrite( *endpoint, ref ) );
            }
            else {
                ShardEndpoint broadcastEndpoint( endpoint->shardName,
                                                 ChunkVersion::IGNORED(),
                                                 endpoint->shardHost );
                targetedWrites->push_back( new TargetedWrite( broadcastEndpoint, ref ) );
            }

            _childOps.back()->pendingWrite = targetedWrites->back();
            _childOps.back()->state = WriteOpState_Pending;
        }

        _state = WriteOpState_Pending;
        return Status::OK();
    }
开发者ID:ukd1,项目名称:mongo,代码行数:71,代码来源:write_op.cpp


示例14: VS

bool TestExtPreg::test_preg_replace() {
  {
    String str = "April 15, 2003";
    String pattern = "/(\\w+) (\\d+), (\\d+)/i";
    String replacement = "${1}1,$3";
    VS(f_preg_replace(pattern, replacement, str), "April1,2003");
  }
  {
    String str = "The quick brown fox jumped over the lazy dog.";
    Variant patterns, replacements;
    patterns.set(0, "/quick/");
    patterns.set(1, "/brown/");
    patterns.set(2, "/fox/");
    replacements.set(2, "bear");
    replacements.set(1, "black");
    replacements.set(0, "slow");
    VS(f_preg_replace(patterns, replacements, str),
       "The bear black slow jumped over the lazy dog.");

    f_ksort(ref(patterns));
    f_ksort(ref(replacements));
    VS(f_preg_replace(patterns, replacements, str),
       "The slow black bear jumped over the lazy dog.");
  }
  {
    Array foos;
    foos.set(0, "foo");
    foos.set(1, "Foo");
    foos.set(2, "FOO");
    Array expFoo;
    expFoo.set(0, "FOO");
    expFoo.set(1, "FOO");
    expFoo.set(2, "FOO");
    VS(f_preg_replace("/some pattern/", "", Array::Create()), Array::Create());
    VS(f_preg_replace("/foo/i", "FOO", foos), expFoo);
  }
  {
    Array patterns = CREATE_VECTOR2("/(19|20)(\\d{2})-(\\d{1,2})-(\\d{1,2})/",
                                    "/^\\s*{(\\w+)}\\s*=/");
    Array replace = CREATE_VECTOR2("\\3/\\4/\\1\\2", "$\\1 =");
    VS(f_preg_replace(patterns, replace, "{startDate} = 1999-5-27"),
       "$startDate = 5/27/1999");
  }
  {
    String str = "foo   o";
    str = f_preg_replace("/\\s\\s+/", " ", str);
    VS(str, "foo o");
  }
  {
    Variant count = 0;
    f_preg_replace(CREATE_VECTOR2("/\\d/", "/\\s/"), "*", "xp 4 to", -1,
                   ref(count));
    VS(count, 3);
  }
  {
    String html_body = "<html><body></body></html>";
    String html_body2 = f_preg_replace("/(<\\/?\\w+[^>]*>)/e",
                               "strtoupper(\"$1\")",
                               html_body);
    VS(html_body2, "<HTML><BODY></BODY></HTML>");

    String css_text = "#AAAA;";
    String css_text2 = f_preg_replace("/#([A-Fa-f0-9]{3,6});/e",
                                      "strtolower(\"#\\1;\");", css_text);
    VS(css_text2, "#aaaa;");

    String rgb_text = "rgb(13, 14, 15)";
    String rgb_text2 =
      f_preg_replace("/rgb\\(([0-9]{1,3}), ([0-9]{1,3}), ([0-9]{1,3})\\)/e",
                     "sprintf(\"%02x%02x%02x\", \"\\1\", \"\\2\", \"\\3\")",
                     rgb_text);
    VS(rgb_text2, "0d0e0f");

    String res = f_preg_replace("/(a*)(b*)/e",
                                "test_preg_rep(\"\\1\",\"smu\\\"rf\",\"\\2\")",
                                "aaabbbblahblahaabbbababab");
    VS(res, "BBBBaaalahBlahBBBaaBaBaBa");

    try {
      f_preg_replace("/(<\\/?)(\\w+)([^>]*>)/e",
                     "'\\\\1'.strtoupper('\\\\2').'\\\\3'",
                     html_body);
    } catch (const NotSupportedException& e) {
      return Count(true);
    }
  }
  return Count(false);
}
开发者ID:CyaLiven,项目名称:hiphop-php,代码行数:88,代码来源:test_ext_preg.cpp


示例15: main

main() {
  var x = 4;
  ref(x);
  return x;
}
开发者ID:pal25,项目名称:eecs345,代码行数:5,代码来源:assignment3-test12.c


示例16: f_collator_sort_with_sort_keys

Variant f_collator_sort_with_sort_keys(CVarRef obj, VRefParam arr) {
  CHECK_COLL(obj);
  return coll->t_sortwithsortkeys(ref(arr));
}
开发者ID:cctech,项目名称:hiphop-php,代码行数:4,代码来源:ext_intl.cpp


示例17: bisystemControl

/**
 * @brief bisystemControl
 * Initiates the bilateral control between master and slave systems
 * @param allSys Vector of pointers to the instantiated DXMotorSystem object pointers
 * @param runFlag Boolean run flag, continues the bilateral control while true - passed by reference to allow changes at runtime
 * @param goalTorqueSetting Desired torque settings to be used (parameters defined as macro in header) - passed by reference to allow modifications at runtime
 * @param filename Prefix filename where recorded position data is saved to
 */
void bisystemControl(vector<DXMotorSystem*>& allSys, bool& runFlag, int& goalTorqueSetting, const string& filename)
{
    try {

        DXMotorSystem dmaster = *(allSys[0]);
        unsigned int numMotors = dmaster.getNumMotors();
        dmaster.setAllTorqueEn(0);
        vector<int> allMasterTorqueLimit(numMotors,MASTER_TORQUE);
        dmaster.setAllTorqueLimit(allMasterTorqueLimit);

        // Check that all systems have the same motor count
        for (unsigned int ii = 1; ii < allSys.size(); ii++)
        {
            if (allSys[ii]->getNumMotors() != numMotors)
                throw(runtime_error("Master and slave motor count do not tally."));
            vector<int> allSlaveTorqueLimit(numMotors, SLAVE_TORQUE);
            allSys[ii]->setAllTorqueLimit(allSlaveTorqueLimit);
        }

        vector<int> posWrite = dmaster.getAllHomePosition(); //dmaster.getAllPosition();
        string writeFilename  = "data/" + filename + getTimeStr() + ".csv";
        ofstream file (writeFilename);

        ostringstream header;
        header << "timestep";
        for (unsigned int ii = 0; ii < numMotors; ii++)
        {
            header << ",#" << ii;
        }
        file << header.str() << endl;

        int torqueSetting = 0;
        vector<int> lowTorques(numMotors,MASTER_LOW_TORQUE);
        vector<int> highTorques(numMotors,MASTER_HIGH_TORQUE);

        vector<queue<vector<int> > > allPosHistory;
        for (unsigned int ii = 0; ii < allSys.size(); ii++)
        {
            queue<vector<int> > posHistory;
            allPosHistory.push_back(posHistory);
        }


        int timestep = 0;
        while(runFlag)
        {
            thread write(write2file, ref(file), ref(posWrite), timestep);

            // Change torque settings of master
            if (torqueSetting != goalTorqueSetting)
            {
                switch(goalTorqueSetting)
                {
                case 1:
                    dmaster.setAllTorqueLimit(lowTorques);
                    dmaster.setAllTorqueEn(1);
                    break;
                case 2:
                    dmaster.setAllTorqueLimit(highTorques);
                    dmaster.setAllTorqueEn(1);
                    break;
                case 0:
                default:
                    dmaster.setAllTorqueLimit(allMasterTorqueLimit);
                    dmaster.setAllTorqueEn(0);
                    break;
                }
                torqueSetting = goalTorqueSetting;
            }

            vector<int> pos = dmaster.getAllPosition();

            thread thr[allSys.size()-1];
            for (unsigned int ii = 0; ii < allSys.size()-1; ii++)
            {
                thr[ii] = thread(setPositions,ref(*(allSys[ii+1])),ref(pos));

//                allSys[ii+1]->setAllPosition(pos);
//                allSys[ii+1]->getAllPosition();
            }
            posWrite = pos; // position data to write (in next time step)

            write.join();
            for (unsigned int ii = 0; ii < allSys.size()-1; ii++)
            {
                thr[ii].join();
            }
            timestep++;
        }

        file.close();
        // Delete pointers
//.........这里部分代码省略.........
开发者ID:KM-RoBoTa,项目名称:DXSystem,代码行数:101,代码来源:bilateralcontrol.cpp


示例18: php_intl_idn_to

static Variant php_intl_idn_to(CStrRef domain, int64 options, IdnVariant idn_variant, VRefParam idna_info, int mode) {
  UChar* ustring = NULL;
  int ustring_len = 0;
  UErrorCode status;
  char     *converted_utf8 = NULL;
  int32_t   converted_utf8_len;
  UChar*    converted = NULL;
  int32_t   converted_ret_len;

  if (idn_variant != INTL_IDN_VARIANT_2003) {
#ifdef HAVE_46_API
    if (idn_variant == INTL_IDN_VARIANT_UTS46) {
      return php_intl_idn_to_46(domain, options, idn_variant, ref(idna_info), mode); 
    } 
#endif
    return false;
  }

  // Convert the string to UTF-16
  status = U_ZERO_ERROR;
  intl_convert_utf8_to_utf16(&ustring, &ustring_len,
      (char*)domain.data(), domain.size(), &status);
  if (U_FAILURE(status)) {
    free(ustring);
    return false;
  }

  // Call the appropriate IDN function
  int converted_len = (ustring_len > 1) ? ustring_len : 1;
  for (;;) {
    UParseError parse_error;
    status = U_ZERO_ERROR;
    converted = (UChar*)malloc(sizeof(UChar)*converted_len);
    // If the malloc failed, bail out
    if (!converted) {
      free(ustring);
      return false;
    }
    if (mode == INTL_IDN_TO_ASCII) {
      converted_ret_len = uidna_IDNToASCII(ustring,
          ustring_len, converted, converted_len,
          (int32_t)options, &parse_error, &status);
    } else {
      converted_ret_len = uidna_IDNToUnicode(ustring,
          ustring_len, converted, converted_len,
          (int32_t)options, &parse_error, &status);
    }
    if (status != U_BUFFER_OVERFLOW_ERROR)
      break;
    // If we have a buffer overflow error, try again with a larger buffer
    free(converted);
    converted = NULL;
    converted_len = converted_len * 2;
  }
  free(ustring);
  if (U_FAILURE(status)) {
    free(converted);
    return false;
  }

  // Convert the string back to UTF-8
  status = U_ZERO_ERROR;
  intl_convert_utf16_to_utf8(&converted_utf8, &converted_utf8_len,
      converted, converted_ret_len, &status);
  free(converted);
  if (U_FAILURE(status)) {
    free(converted_utf8);
    return false;
  }

  // Return the string
  return String(converted_utf8, converted_utf8_len, AttachString);
}
开发者ID:cctech,项目名称:hiphop-php,代码行数:73,代码来源:ext_intl.cpp


示例19: VERIFY

bool TestExtNetwork::test_getmxrr() {
  Variant hosts;
  VERIFY(f_getmxrr("facebook.com", ref(hosts)));
  VERIFY(!hosts.toArray().empty());
  return Count(true);
}
开发者ID:mukulu,项目名称:hiphop-php,代码行数:6,代码来源:test_ext_network.cpp


示例20: baseurl

bool TestExtServer::test_pagelet_server_task_result() {
  const int TEST_SIZE = 20;

  String baseurl("ext/pageletserver?getparam=");
  String baseheader("MyHeader: ");
  String basepost("postparam=");

  std::vector<Resource> tasks;
  for (int i = 0; i < TEST_SIZE; ++i) {
    String url = baseurl + String(i);
    String header = baseheader + String(i);
    String post = basepost + String(i);
    Resource task = HHVM_FN(pagelet_server_task_start)(url,
      make_packed_array(header), post);
    tasks.push_back(task);
  }

  for (int i = 0; i < TEST_SIZE; ++i) {
    HHVM_FN(pagelet_server_task_status)(tasks[i]);
  }

  // Calls that time out (try 1 ms) should return a status code of -1
  for (int i = 0; i < TEST_SIZE; ++i) {
    Variant code, headers;
    VS("", HHVM_FN(pagelet_server_task_result)(tasks[i], ref(headers),
                                               ref(code), 1));
    VS(code, -1);
  }

  for (int i = 0; i < TEST_SIZE; ++i)  {
    String expected = "pagelet postparam: postparam=";
    expected += String(i);
    expected += "pagelet getparam: ";
    expected += String(i);
    expected += "pagelet header: ";
    expected += String(i);

    // A timeout of 0 indicates an infinite timeout that blocks.
    Variant code, headers;
    VS(expected, HHVM_FN(pagelet_server_task_result)(tasks[i], ref(headers),
                                                     ref(code), 0));
    VS(code, 200);

    Array headerArray = headers.toArray();
    bool hasResponseHeader = false;
    String expectedHeader = String("ResponseHeader: okay");

    for (int headerIdx = 0; headerIdx < headerArray.size(); headerIdx++) {
      if (headerArray[headerIdx].toString() == expectedHeader) {
        hasResponseHeader = true;
        break;
      }
    }
    VERIFY(hasResponseHeader);
    VS(expected, HHVM_FN(pagelet_server_task_result)(tasks[i], ref(headers),
                                                     ref(code), 1));
    VS(code, 200);
  }

  return Count(true);
}
开发者ID:292388900,项目名称:hhvm,代码行数:61,代码来源:test_ext_server.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ refGrad函数代码示例发布时间:2022-05-30
下一篇:
C++ redraw_screen函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap