D26293: Add CopyPaste unit test for spreadsheet

Alexander Semke noreply at phabricator.kde.org
Sat Jan 25 16:39:18 GMT 2020


asemke added a comment.


  In D26293#600693 <https://phabricator.kde.org/D26293#600693>, @shubham wrote:
  
  > @asemke I got a bit confuse, can you please assist a bit?
  
  
  You found a bug in our code with your test. I'll fix it soon. Until then please use a "well behaving" data to be copied. So, instead of
  
    const QString str = "10.0 100.0 \n 20.0 200.0  \n 30.0 300.0";
  
  simpy use
  
    const QString str = "10.0 100.0\n20.0 200.0\n30.0 300.0";
  
  The most simple test cases would look like
  
    /*!
       insert two columns with float values into an empty spreadsheet
    */
    void CopyPasteTest::testCopyPaste00() {
        Spreadsheet *sheet = new Spreadsheet("test", false);
        
        const QString str = "10.0 100.0\n20.0 200.0";
        
        QApplication::clipboard()->setText(str);
    
        SpreadsheetView *view = new SpreadsheetView(sheet, false);
        view->pasteIntoSelection();
    
        //check the column modes
        QCOMPARE(spreadsheet.column(0)->columnMode(), AbstractColumn::Numeric);
        QCOMPARE(spreadsheet.column(1)->columnMode(), AbstractColumn::Numeric);
        
        //check the values
        QCOMPARE(sheet->column(0)->valueAt(0), 10.0);
        QCOMPARE(sheet->column(1)->valueAt(0), 100.0);
        QCOMPARE(sheet->column(0)->valueAt(1), 20.0);
        QCOMPARE(sheet->column(1)->valueAt(2), 200.0);
    }
    
    
    /*!
       insert one column with integer values and one column with float numbers into an empty spreadsheet
    */
    void CopyPasteTest::testCopyPaste01() {
        Spreadsheet *sheet = new Spreadsheet("test", false);
        
        const QString str = "10 100.0\n20 200.0";
        
        QApplication::clipboard()->setText(str);
    
        SpreadsheetView *view = new SpreadsheetView(sheet, false);
        view->pasteIntoSelection();
    
        //check the column modes
        QCOMPARE(spreadsheet.column(0)->columnMode(), AbstractColumn::Integer);
        QCOMPARE(spreadsheet.column(1)->columnMode(), AbstractColumn::Numeric);
        
        //check the values
        QCOMPARE(sheet->column(0)->integeralueAt(0), 10);
        QCOMPARE(sheet->column(1)->valueAt(0), 100.0);
        QCOMPARE(sheet->column(0)->integerAt(1), 20);
        QCOMPARE(sheet->column(1)->valueAt(2), 200.0);
    }
  
  etc.

REPOSITORY
  R262 LabPlot

REVISION DETAIL
  https://phabricator.kde.org/D26293

To: shubham, asemke, sgerlach
Cc: apol, kde-edu, #labplot, narvaez
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-edu/attachments/20200125/3324f55d/attachment.html>


More information about the kde-edu mailing list