コード例 #1
0
        SanityChecker ()
        {
            SemanticVersion v;

            char const* const rawText = getRawVersionString ();

            if (! v.parse (rawText) || v.print () != rawText)
                FatalError ("Bad server version string", __FILE__, __LINE__);

            versionString = rawText;
        }
コード例 #2
0
ファイル: SemanticVersion.cpp プロジェクト: E-LLP/rippled
    void checkPass (std::string const& input, bool shouldPass = true)
    {
        SemanticVersion v;

        if (shouldPass )
        {
            expect (v.parse (input));
            expect (v.print () == input);
        }
        else
        {
            expect (! v.parse (input));
        }
    }
コード例 #3
0
ファイル: SemanticVersion.cpp プロジェクト: E-LLP/rippled
    // makes sure the left version is less than the right
    void checkLessInternal (std::string const& lhs, std::string const& rhs)
    {
        SemanticVersion left;
        SemanticVersion right;

        expect (left.parse (lhs));
        expect (right.parse (rhs));

        expect (compare (left, left) == 0);
        expect (compare (right, right) == 0);
        expect (compare (left, right) < 0);
        expect (compare (right, left) > 0);

        expect (left < right);
        expect (right > left);
        expect (left == left);
        expect (right == right);
    }
コード例 #4
0
ファイル: SemanticVersion.cpp プロジェクト: E-LLP/rippled
    // Checks the decomposition of the input into appropriate values
    void checkValues (std::string const& input,
        int majorVersion,
        int minorVersion,
        int patchVersion,
        identifier_list const& preReleaseIdentifiers = identifier_list (),
        identifier_list const& metaData = identifier_list ())
    {
        SemanticVersion v;

        expect (v.parse (input));

        expect (v.majorVersion == majorVersion);
        expect (v.minorVersion == minorVersion);
        expect (v.patchVersion == patchVersion);

        expect (v.preReleaseIdentifiers == preReleaseIdentifiers);
        expect (v.metaData == metaData);
    }
コード例 #5
0
ファイル: SemanticVersion.cpp プロジェクト: E-LLP/rippled
int compare (SemanticVersion const& lhs, SemanticVersion const& rhs)
{
    if (lhs.majorVersion > rhs.majorVersion)
        return 1;
    else if (lhs.majorVersion < rhs.majorVersion)
        return -1;

    if (lhs.minorVersion > rhs.minorVersion)
        return 1;
    else if (lhs.minorVersion < rhs.minorVersion)
        return -1;

    if (lhs.patchVersion > rhs.patchVersion)
        return 1;
    else if (lhs.patchVersion < rhs.patchVersion)
        return -1;

    if (lhs.isPreRelease () || rhs.isPreRelease ())
    {
        // Pre-releases have a lower precedence
        if (lhs.isRelease () && rhs.isPreRelease ())
            return 1;
        else if (lhs.isPreRelease () && rhs.isRelease ())
            return -1;

        // Compare pre-release identifiers
        for (int i = 0; i < std::max (lhs.preReleaseIdentifiers.size (), rhs.preReleaseIdentifiers.size ()); ++i)
        {
            // A larger list of identifiers has a higher precedence
            if (i >= rhs.preReleaseIdentifiers.size ())
                return 1;
            else if (i >= lhs.preReleaseIdentifiers.size ())
                return -1;

            std::string const& left (lhs.preReleaseIdentifiers [i]);
            std::string const& right (rhs.preReleaseIdentifiers [i]);

            // Numeric identifiers have lower precedence
            if (! isNumeric (left) && isNumeric (right))
                return 1;
            else if (isNumeric (left) && ! isNumeric (right))
                return -1;

            if (isNumeric (left))
            {
                assert(isNumeric (right));

                int const iLeft (lexicalCastThrow <int> (left));
                int const iRight (lexicalCastThrow <int> (right));

                if (iLeft > iRight)
                    return 1;
                else if (iLeft < iRight)
                    return -1;
            }
            else
            {
                assert (! isNumeric (right));

                int result = left.compare (right);

                if (result != 0)
                    return result;
            }
        }
    }

    // metadata is ignored

    return 0;
}