import 'package:calorimeter/storage/storage.dart'; import 'package:test/test.dart'; void main() { group( 'Test custom split with ignore', () { test('string without ignoring', () { var testString = 'This is a test string'; var resultingList = testString.splitWithIgnore(' '); expect(resultingList[0], equals('This')); expect(resultingList[1], equals('is')); expect(resultingList[2], equals('a')); expect(resultingList[3], equals('test')); expect(resultingList[4], equals('string')); }); test('string that does not contain the ignored character', () { var testString = 'This is a test string'; var resultingList = testString.splitWithIgnore(' ', ignoreIn: '"'); expect(resultingList[0], equals('This')); expect(resultingList[1], equals('is')); expect(resultingList[2], equals('a')); expect(resultingList[3], equals('test')); expect(resultingList[4], equals('string')); }); test( 'string that contains ignored character', () { var testString = 'This is "a test" string'; var resultingList = testString.splitWithIgnore(' ', ignoreIn: '"'); expect(resultingList[0], equals('This')); expect(resultingList[1], equals('is')); expect(resultingList[2], equals('"a test"')); expect(resultingList[3], equals('string')); }, ); test( 'string that contains commas that should be ignored', () { var testString = 'f9a96b80-71f9-11ef-8df4-f3628a737a16,"Erdnüsse, geröstet",120.0,100.0'; var resultingList = testString.splitWithIgnore(',', ignoreIn: '"'); expect( resultingList[0], equals('f9a96b80-71f9-11ef-8df4-f3628a737a16')); expect(resultingList[1], equals('"Erdnüsse, geröstet"')); expect(resultingList[2], equals('120.0')); expect(resultingList[3], equals('100.0')); }, ); }, ); }