• <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>
  • CPPUnit實例Simple class

    發表于:2009-04-03來源:作者:點擊數: 標簽:CPPUnitcppunitCppUnitcppUnitSimple
    1. CppUnit是xUnit系列中的c++實現版本,它是從JUnit移植過來的,第一個移植版本由Michael Feathers完成,安裝 cppunit ,你可以在此下載cppunit的最新版本,最新版本是CppUnit release 1.12.0,安裝方法,現解壓,然后到文件夾下找到INSTALL-WIN32.txt( win
      1. CppUnit是xUnit系列中的c++實現版本,它是從JUnit移植過來的,第一個移植版本由Michael Feathers完成,安裝cppunit,你可以在此下載cppunit的最新版本,最新版本是CppUnit release 1.12.0,安裝方法,現解壓,然后到文件夾下找到INSTALL-WIN32.txt(windows平臺)

            2.打開\examples下的examples.dsw,編譯鏈接即可完成。

            3.分析所要測試的類class

    class Money
    {
    public:
      Money( double amount, std::string currency )
        : m_amount( amount )
        , m_currency( currency )
      {
      }

      double getAmount() const
      {
        return m_amount;
      }

      std::string getCurrency() const
      {
        return m_currency;
      }

      bool operator ==( const Money &other ) const
      {
        return m_amount == other.m_amount  && 
               m_currency == other.m_currency;
      }

      bool operator !=( const Money &other ) const
      {
        return !(*this == other);
      }

      Money &operator +=( const Money &other )
      {
        if ( m_currency != other.m_currency )
          throw IncompatibleMoneyError();

        m_amount += other.m_amount;
        return *this;
      }

    private:
      double m_amount;
      std::string m_currency;
    };

            4. 所要測試的有哪些接口呢?

            我們分析一下這個類的公開的屬性和方法。這些都是我們要測試的接口。

    構造函數
    Money( double amount, std::string currency )
    接口函數有
    double getAmount() const
    std::string getCurrency() const
    bool operator ==( const Money &other ) const
    bool operator !=( const Money &other ) const
    Money &operator +=( const Money &other )

    原文轉自:http://www.kjueaiud.com

    老湿亚洲永久精品ww47香蕉图片_日韩欧美中文字幕北美法律_国产AV永久无码天堂影院_久久婷婷综合色丁香五月

  • <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>