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


C++ DoCompare函数代码示例

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


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

示例1: test_gte_lte

void test_gte_lte(void)
{
    assert_int_equal(DoCompare("1.0-1", "1.0-1", PACKAGE_VERSION_COMPARATOR_GE), VERCMP_MATCH);
    assert_int_equal(DoCompare("1.0-1", "1.0-2", PACKAGE_VERSION_COMPARATOR_GE), VERCMP_NO_MATCH);
    assert_int_equal(DoCompare("1.0-2", "1.0-1", PACKAGE_VERSION_COMPARATOR_GE), VERCMP_MATCH);
    assert_int_equal(DoCompare("1.0-1", "1.0-1", PACKAGE_VERSION_COMPARATOR_LE), VERCMP_MATCH);
    assert_int_equal(DoCompare("1.0-1", "1.0-2", PACKAGE_VERSION_COMPARATOR_LE), VERCMP_MATCH);
    assert_int_equal(DoCompare("1.0-2", "1.0-1", PACKAGE_VERSION_COMPARATOR_LE), VERCMP_NO_MATCH);
}
开发者ID:cduclos,项目名称:core,代码行数:9,代码来源:package_versions_compare_test.c

示例2: test_gte_lte

void test_gte_lte(void)
{
    assert_int_equal(DoCompare("1.0-1", "1.0-1", PACKAGE_VERSION_COMPARATOR_GE), true);
    assert_int_equal(DoCompare("1.0-1", "1.0-2", PACKAGE_VERSION_COMPARATOR_GE), false);
    assert_int_equal(DoCompare("1.0-2", "1.0-1", PACKAGE_VERSION_COMPARATOR_GE), true);
    assert_int_equal(DoCompare("1.0-1", "1.0-1", PACKAGE_VERSION_COMPARATOR_LE), true);
    assert_int_equal(DoCompare("1.0-1", "1.0-2", PACKAGE_VERSION_COMPARATOR_LE), true);
    assert_int_equal(DoCompare("1.0-2", "1.0-1", PACKAGE_VERSION_COMPARATOR_LE), false);
}
开发者ID:nperron,项目名称:core,代码行数:9,代码来源:package_versions_compare_test.c

示例3: switch

int MultiSortFilterProxy::Compare(const QVariant& left,
                                  const QVariant& right) const {
  // Copied from the QSortFilterProxyModel::lessThan implementation, but returns
  // -1, 0 or 1 instead of true or false.
  switch (left.userType()) {
    case QVariant::Invalid:
      return (right.type() != QVariant::Invalid) ? -1 : 0;
    case QVariant::Int:
      return DoCompare(left.toInt(), right.toInt());
    case QVariant::UInt:
      return DoCompare(left.toUInt(), right.toUInt());
    case QVariant::LongLong:
      return DoCompare(left.toLongLong(), right.toLongLong());
    case QVariant::ULongLong:
      return DoCompare(left.toULongLong(), right.toULongLong());
    case QMetaType::Float:
      return DoCompare(left.toFloat(), right.toFloat());
    case QVariant::Double:
      return DoCompare(left.toDouble(), right.toDouble());
    case QVariant::Char:
      return DoCompare(left.toChar(), right.toChar());
    case QVariant::Date:
      return DoCompare(left.toDate(), right.toDate());
    case QVariant::Time:
      return DoCompare(left.toTime(), right.toTime());
    case QVariant::DateTime:
      return DoCompare(left.toDateTime(), right.toDateTime());
    case QVariant::String:
    default:
      if (isSortLocaleAware())
        return left.toString().localeAwareCompare(right.toString());
      else
        return left.toString().compare(right.toString(), sortCaseSensitivity());
  }

  return 0;
}
开发者ID:Aceler,项目名称:Clementine,代码行数:37,代码来源:multisortfilterproxy.cpp

示例4: TypeCmp

typecmp_t TypeCmp (const Type* lhs, const Type* rhs)
/* Compare two types and return the result */
{
    /* Assume the types are identical */
    typecmp_t   Result = TC_IDENTICAL;

#if 0
    printf ("Left : "); PrintRawType (stdout, lhs);
    printf ("Right: "); PrintRawType (stdout, rhs);
#endif

    /* Recursively compare the types if they aren't identical */
    if (rhs != lhs) {
        DoCompare (lhs, rhs, &Result);
    }

    /* Return the result */
    return Result;
}
开发者ID:JackieXie168,项目名称:cc65,代码行数:19,代码来源:typecmp.c

示例5: invalid_08

void invalid_08(void)
{
    assert_int_equal(DoCompare("1.0", "text-1.0", PACKAGE_VERSION_COMPARATOR_GT), VERCMP_ERROR);
}
开发者ID:cduclos,项目名称:core,代码行数:4,代码来源:package_versions_compare_test.c

示例6: uneven_lengths_20

void uneven_lengths_20(void)
{
    assert_int_equal(DoCompare("1.0", "1.0-1", PACKAGE_VERSION_COMPARATOR_LE), VERCMP_MATCH);
}
开发者ID:cduclos,项目名称:core,代码行数:4,代码来源:package_versions_compare_test.c

示例7: uneven_lengths_7

void uneven_lengths_7(void)
{
    assert_int_equal(DoCompare("1.0", "1.0.1", PACKAGE_VERSION_COMPARATOR_GT), VERCMP_NO_MATCH);
}
开发者ID:cduclos,项目名称:core,代码行数:4,代码来源:package_versions_compare_test.c

示例8: wrong_separators

void wrong_separators(void)
{
    assert_int_equal(DoCompare("1.0", "1,0", PACKAGE_VERSION_COMPARATOR_EQ), VERCMP_ERROR);
}
开发者ID:cduclos,项目名称:core,代码行数:4,代码来源:package_versions_compare_test.c

示例9: DoOneExternalTest


//.........这里部分代码省略.........

        cmdResult = ExecuteCommand(pDir->GetFullPathFromSourceOrDirectory(), cmdbuf, millisecTimeout, envFlags);

        if (cmdResult && cmdResult != WAIT_TIMEOUT && !pTestVariant->testInfo.data[TIK_BASELINE]) // failure code, not baseline diffing
        {
            fFailed = TRUE;
            sprintf_s(nonZeroReturnBuf, "non-zero (%08X) return value from test command", cmdResult);
            reason = nonZeroReturnBuf;
            goto logFailure;
        }
    }
    else
    {
        ASSERTNR(UNREACHED);
        cmdResult = NOERROR; // calm compiler warning about uninitialized variable usage
    }

    // Check for timeout.

    if (cmdResult == WAIT_TIMEOUT) {
        ASSERT(millisecTimeout != INFINITE);
        sprintf_s(nonZeroReturnBuf, "timed out after %u second%s", millisecTimeout / 1000, millisecTimeout == 1000 ? "" : "s");
        reason = nonZeroReturnBuf;
        fFailed = TRUE;
        goto logFailure;
    }

    // If we have a baseline test, we need to check the baseline file.
    if (pTestVariant->testInfo.data[TIK_BASELINE]) {
        char baseline_file[_MAX_PATH];

        sprintf_s(baseline_file, "%s\\%s", pDir->GetFullPathFromSourceOrDirectory(),
            pTestVariant->testInfo.data[TIK_BASELINE]);
        if (DoCompare(baseline_file, full, pTestVariant->testInfo.hasData[TIK_EOL_NORMALIZATION])) {
            reason = "diffs from baseline";
            sprintf_s(optReportBuf, "%s", baseline_file);
            fFailed = TRUE;
            CopyRebaseFile(full, baseline_file);
        }
    }
    else if ((kind == TK_JSCRIPT || kind == TK_HTML || kind == TK_COMMAND) && !pTestVariant->testInfo.hasData[TIK_BASELINE]) {
        if (!CheckForPass(full, optReportBuf, cmdbuf, fDumpOutputFile)) {
            fFailed = TRUE;
            goto SkipLogFailure;
        }
    }

logFailure:
    if (fFailed) {
        LogOut("ERROR: Test failed to run correctly: %s (%s):",
            reason, optReportBuf);
        LogOut("    %s", cmdbuf);
        if (fDumpOutputFile) {
            DumpFileToLog(full);
        }
    }

SkipLogFailure:
    if (fFileToDelete && !FNoDelete) {
        DeleteFileRetryMsg(full);
    }

    elapsed_variation = (int)(time(NULL) - start_variation);
    if (Timing & TIME_VARIATION) {
        Message("RL: Variation elapsed time (%s, %s, %s): %02d:%02d",
            pDir->GetDirectoryName(),
开发者ID:mrkmarron,项目名称:ChakraCore,代码行数:67,代码来源:rlrun.cpp

示例10: uneven_lengths_19

void uneven_lengths_19(void)
{
    assert_int_equal(DoCompare("1.0", "1.0-1", PACKAGE_VERSION_COMPARATOR_GE), false);
}
开发者ID:nperron,项目名称:core,代码行数:4,代码来源:package_versions_compare_test.c

示例11: uneven_lengths_18

void uneven_lengths_18(void)
{
    assert_int_equal(DoCompare("1.0", "1.0-1", PACKAGE_VERSION_COMPARATOR_LT), true);
}
开发者ID:nperron,项目名称:core,代码行数:4,代码来源:package_versions_compare_test.c

示例12: test_eq

void test_eq(void)
{
    assert_int_equal(DoCompare("1.0-1", "1.0-1", PACKAGE_VERSION_COMPARATOR_EQ), true);
    assert_int_equal(DoCompare("1.0-1", "1.0-1", PACKAGE_VERSION_COMPARATOR_NONE), true);
    assert_int_equal(DoCompare("1.0-1", "1.0-2", PACKAGE_VERSION_COMPARATOR_EQ), false);
}
开发者ID:nperron,项目名称:core,代码行数:6,代码来源:package_versions_compare_test.c

示例13: compareHex

void compareHex(void)
{
	DoCompare();
	DialogUpdate();
	setMenu();
}
开发者ID:zxjqazwsx,项目名称:HexEditor_0_9_5_git,代码行数:6,代码来源:Hex.cpp

示例14: DoOneSimpleTest


//.........这里部分代码省略.........

    // Make sure the output file isn't there.

    DeleteFileIfFound(tmp_file1);

    fFailed = FALSE;

    // Check for timeout.
    {
        int retval = ExecuteCommand(pDir->GetDirectoryPath(), buf, millisecTimeout, envFlags);
        if (retval == WAIT_TIMEOUT) {
            ASSERT(millisecTimeout != INFINITE);
            LogOut("ERROR: Test timed out after %ul seconds", millisecTimeout / 1000);
            fFailed = TRUE;
            goto logFailure;
        }
    }

    // Check the output.

    if (pTestVariant->testInfo.data[TIK_BASELINE]) {
        int spiff_ret;

        // Check to see if the exe ran at all.

        if (GetFileAttributes(tmp_file1) == INVALID_FILE_ATTRIBUTES) {
            LogOut("ERROR: Test failed to run. Couldn't find file '%s' (%s):", tmp_file1, optReportBuf);
            LogOut("    %s", cmdbuf);
            fFailed = TRUE;
        }
        else {
            sprintf_s(full, "%s\\%s", pDir->GetFullPathFromSourceOrDirectory(),
                pTestVariant->testInfo.data[TIK_BASELINE]);
            if (DoCompare(tmp_file1, full, pTestVariant->testInfo.hasData[TIK_EOL_NORMALIZATION])) {

                // Output differs, run spiff to see if it's just minor
                // floating point anomalies.

                DeleteFileIfFound(tmp_file2);
                sprintf_s(buf, "spiff -m -n -s \"command spiff\" %s %s > %s",
                    tmp_file1, full, tmp_file2);
                spiff_ret = ExecuteCommand(pDir->GetDirectoryPath(), buf);
                if (GetFileAttributes(tmp_file2) == INVALID_FILE_ATTRIBUTES) {
                    LogError("ERROR: spiff failed to run");
                    fFailed = TRUE;
                }
                else if (spiff_ret) {
                    LogOut("ERROR: Test failed to run correctly. spiff returned %d (%s):", spiff_ret, optReportBuf);
                    LogOut("    %s", cmdbuf);
                    fFailed = TRUE;
                }
            }
        }
    }
    else {
        if (!CheckForPass(tmp_file1, optReportBuf, cmdbuf)) {
            fFailed = TRUE;
        }
    }

logFailure:

    if (fFailed) {
        if (FCopyOnFail) {
            if (FVerbose)
                Message("INFO: Copying '%s' failure", optReportBuf);
开发者ID:mrkmarron,项目名称:ChakraCore,代码行数:67,代码来源:rlrun.cpp

示例15: test_different_name

void test_different_name(void)
{
    EvalContext *ctx = EvalContextNew();
    PromiseResult result;

    PackageItem pi = {
        .name = "pkgone",
        .version = "1",
        .arch = "arch"
    };
    Attributes attr = {
        .packages = {
            .package_select = PACKAGE_VERSION_COMPARATOR_EQ
        }
    };

    assert_int_equal(ComparePackages(ctx, "pkgtwo", "1", "arch", &pi, attr, NULL, "test", &result), VERCMP_NO_MATCH);

    EvalContextDestroy(ctx);
}

void test_wildcard_arch(void)
{
    EvalContext *ctx = EvalContextNew();
    PromiseResult result;

    PackageItem pi = {
        .name = "foobar",
        .version = "1",
        .arch = "arch"
    };
    Attributes attr = {
        .packages = {
            .package_select = PACKAGE_VERSION_COMPARATOR_EQ
        }
    };

    assert_int_equal(ComparePackages(ctx, "foobar", "1", "*", &pi, attr, NULL, "test", &result), VERCMP_MATCH);

    EvalContextDestroy(ctx);
}

void test_non_matching_arch(void)
{
    EvalContext *ctx = EvalContextNew();
    PromiseResult result;

    PackageItem pi = {
        .name = "foobar",
        .version = "1",
        .arch = "s390x"
    };
    Attributes attr = {
        .packages = {
            .package_select = PACKAGE_VERSION_COMPARATOR_EQ
        }
    };

    assert_int_equal(ComparePackages(ctx, "foobar", "1", "s390", &pi, attr, NULL, "test", &result), VERCMP_NO_MATCH);

    EvalContextDestroy(ctx);
}

VersionCmpResult DoCompare(const char *lhs, const char *rhs, PackageVersionComparator cmp)
{
    EvalContext *ctx = EvalContextNew();
    PromiseResult result;

    PackageItem pi = {
        .name = "foobar",
        .version = (char*)lhs,
        .arch = "somearch"
    };
    Attributes a = {
        .packages = {
            .package_select = cmp,
        }
    };

    VersionCmpResult cmp_result = ComparePackages(ctx, "foobar", rhs, "somearch", &pi, a, NULL, "test", &result);

    EvalContextDestroy(ctx);

    return cmp_result;
}

void test_wildcard_version(void)
{
    assert_int_equal(DoCompare("1.0-1", "*", PACKAGE_VERSION_COMPARATOR_EQ), VERCMP_MATCH);
}
开发者ID:cduclos,项目名称:core,代码行数:90,代码来源:package_versions_compare_test.c


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