[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-edu-devel
Subject:    D26293: Add CopyPaste unit test for spreadsheet
From:       Alexander Semke <noreply () phabricator ! kde ! org>
Date:       2020-01-25 16:39:18
Message-ID: 089a71e23ef728da96852a79c027216c () localhost ! localdomain
[Download RAW message or body]

[Attachment #2 (text/plain)]

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


[Attachment #3 (text/html)]

<table><tr><td style="">asemke added a comment.
</td><a style="text-decoration: none; padding: 4px 8px; margin: 0 8px 8px; float: \
right; color: #464C5C; font-weight: bold; border-radius: 3px; background-color: \
#F7F7F9; background-image: linear-gradient(to bottom,#fff,#f1f0f1); display: \
inline-block; border: 1px solid rgba(71,87,120,.2);" \
href="https://phabricator.kde.org/D26293">View Revision</a></tr></table><br \
/><div><div><blockquote style="border-left: 3px solid #8C98B8;  color: #6B748C;
          font-style: italic;
          margin: 4px 0 12px 0;
          padding: 8px 12px;
          background-color: #F8F9FC;">
<div style="font-style: normal;
          padding-bottom: 4px;">In <a \
href="https://phabricator.kde.org/D26293#600693" style="background-color: #e7e7e7;  \
border-color: #e7e7e7;  border-radius: 3px;
          padding: 0 4px;
          font-weight: bold;
          color: black;text-decoration: none;">D26293#600693</a>, <a \
href="https://phabricator.kde.org/p/shubham/" style="  border-color: #f1f7ff;
              color: #19558d;
              background-color: #f1f7ff;
                border: 1px solid transparent;
                border-radius: 3px;
                font-weight: bold;
                padding: 0 4px;">@shubham</a> wrote:</div>
<div style="margin: 0;
          padding: 0;
          border: 0;
          color: rgb(107, 116, 140);"><p><a \
href="https://phabricator.kde.org/p/asemke/" style="  border-color: #f1f7ff;
              color: #19558d;
              background-color: #f1f7ff;
                border: 1px solid transparent;
                border-radius: 3px;
                font-weight: bold;
                padding: 0 4px;">@asemke</a> I got a bit confuse, can you please \
assist a bit?</p></div> </blockquote>

<p>You found a bug in our code with your test. I&#039;ll fix it soon. Until then \
please use a &quot;well behaving&quot; data to be copied. So, instead of</p>

<div class="remarkup-code-block" style="margin: 12px 0;" data-code-lang="text" \
data-sigil="remarkup-code-block"><pre class="remarkup-code" style="font: 11px/15px \
&quot;Menlo&quot;, &quot;Consolas&quot;, &quot;Monaco&quot;, monospace; padding: \
12px; margin: 0; background: rgba(71, 87, 120, 0.08);">const QString str = &quot;10.0 \
100.0 \n 20.0 200.0  \n 30.0 300.0&quot;;</pre></div>

<p>simpy use</p>

<div class="remarkup-code-block" style="margin: 12px 0;" data-code-lang="text" \
data-sigil="remarkup-code-block"><pre class="remarkup-code" style="font: 11px/15px \
&quot;Menlo&quot;, &quot;Consolas&quot;, &quot;Monaco&quot;, monospace; padding: \
12px; margin: 0; background: rgba(71, 87, 120, 0.08);">const QString str = &quot;10.0 \
100.0\n20.0 200.0\n30.0 300.0&quot;;</pre></div>

<p>The most simple test cases would look like</p>

<div class="remarkup-code-block" style="margin: 12px 0;" data-code-lang="text" \
data-sigil="remarkup-code-block"><pre class="remarkup-code" style="font: 11px/15px \
&quot;Menlo&quot;, &quot;Consolas&quot;, &quot;Monaco&quot;, monospace; padding: \
12px; margin: 0; background: rgba(71, 87, 120, 0.08);">/*!  insert two columns with \
                float values into an empty spreadsheet
*/
void CopyPasteTest::testCopyPaste00() {
    Spreadsheet *sheet = new Spreadsheet(&quot;test&quot;, false);
    
    const QString str = &quot;10.0 100.0\n20.0 200.0&quot;;
    
    QApplication::clipboard()-&gt;setText(str);

    SpreadsheetView *view = new SpreadsheetView(sheet, false);
    view-&gt;pasteIntoSelection();

    //check the column modes
    QCOMPARE(spreadsheet.column(0)-&gt;columnMode(), AbstractColumn::Numeric);
    QCOMPARE(spreadsheet.column(1)-&gt;columnMode(), AbstractColumn::Numeric);
    
    //check the values
    QCOMPARE(sheet-&gt;column(0)-&gt;valueAt(0), 10.0);
    QCOMPARE(sheet-&gt;column(1)-&gt;valueAt(0), 100.0);
    QCOMPARE(sheet-&gt;column(0)-&gt;valueAt(1), 20.0);
    QCOMPARE(sheet-&gt;column(1)-&gt;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(&quot;test&quot;, false);
    
    const QString str = &quot;10 100.0\n20 200.0&quot;;
    
    QApplication::clipboard()-&gt;setText(str);

    SpreadsheetView *view = new SpreadsheetView(sheet, false);
    view-&gt;pasteIntoSelection();

    //check the column modes
    QCOMPARE(spreadsheet.column(0)-&gt;columnMode(), AbstractColumn::Integer);
    QCOMPARE(spreadsheet.column(1)-&gt;columnMode(), AbstractColumn::Numeric);
    
    //check the values
    QCOMPARE(sheet-&gt;column(0)-&gt;integeralueAt(0), 10);
    QCOMPARE(sheet-&gt;column(1)-&gt;valueAt(0), 100.0);
    QCOMPARE(sheet-&gt;column(0)-&gt;integerAt(1), 20);
    QCOMPARE(sheet-&gt;column(1)-&gt;valueAt(2), 200.0);
}</pre></div>

<p>etc.</p></div></div><br /><div><strong>REPOSITORY</strong><div><div>R262 \
LabPlot</div></div></div><br /><div><strong>REVISION DETAIL</strong><div><a \
href="https://phabricator.kde.org/D26293">https://phabricator.kde.org/D26293</a></div></div><br \
/><div><strong>To: </strong>shubham, asemke, sgerlach<br /><strong>Cc: </strong>apol, \
kde-edu, LabPlot, narvaez<br /></div>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic