⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 expecter.h

📁 symbian 3rd下的单元测试工具 里面包括一个框架 一个实例程序 还有使用手册 很好用的 我自己用过 有问题的可以交流奥
💻 H
字号:
#ifndef __CXXTEST__EXPECTER_H
#define __CXXTEST__EXPECTER_H

#include <cxxtest/TestSuite.h>

namespace CxxTest
{
    class Expecter : public TestSuite
    {
    public:
        Expecter() : TestSuite(), _expected( "" ) {}

    protected:
        void expect( const char *expected )
        {
            _expected = fixNull( expected );
        }

        void found( const char *file, unsigned line, const char *foundString )
        {
            foundString = fixNull( foundString );
            if ( !stringsEqual( _expected, foundString ) )
                failedExpectation( file, line, _expected, foundString );
            nextExpected();
        }
        
#       define TS_EXPECT(ss) expect(ss)
#       define TS_FOUND(f) found(__FILE__, __LINE__, f )
#       define TS_END() found(__FILE__, __LINE__, "" )
        
    private:
        const char *_expected;

        static const char *fixNull( const char *str )
        {
            return str ? str : "";
        }

        static bool stringsEqual( const char *s1, const char *s2 )
        {
            char c;
            while ( (c = *s1++) == *s2++ )
                if ( c == '\0' )
                    return true;
            return false;
        }

        void nextExpected( void )
        {
            if ( *_expected == '\0' )
                return;
            while ( *_expected++ != '\0' )
                ;
        }
    };
};

#endif // __CXXTEST__EXPECTER_H

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -