Ignore:
Timestamp:
May 4, 2011, 9:53:40 AM (9 years ago)
Author:
s.h.sikkema@…
Message:

Improved CSV export

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/dbnp/studycapturing/AssayServiceTests.groovy

    r1790 r1803  
    262262//    }
    263263
    264 
     264    void testCSVOutput() {
     265
     266        // We're testing:
     267        // - strings containing any newlines, comma's, or double quotes should
     268        //   be surrounded with double quotes
     269        // - double quotes should be escaped by double quotes ( " -> "" )
     270        // - other strings and numbers should remain 'quoteless'
     271
     272        def rowData = [["""a
     273b""","a,b","a\"b", "abc"],[1,2.0,"3,1"]]
     274
     275        def baos = new ByteArrayOutputStream()
     276
     277        service.exportRowWiseDataToCSVFile rowData, baos
     278
     279        assertEquals 'CSV Output', '"a\nb","a,b","a""b",abc\n1,2.0,"3,1"', baos.toString()
     280
     281    }
    265282}
Note: See TracChangeset for help on using the changeset viewer.