-
-
Save daniel-v/e6d016374474eb257cdb8f92f0606bbb to your computer and use it in GitHub Desktop.
XML package test case
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:test/test.dart'; | |
import 'package:xml/xml.dart'; | |
final String xmlWithoutGt = ''' | |
<?xml version="1.0" encoding="utf-8"?> | |
<doc> | |
<test> | |
You shall do pass | |
</test> | |
</doc> | |
'''; | |
final String xmlWithGt = ''' | |
<?xml version="1.0" encoding="utf-8"?> | |
<doc> | |
<test> | |
<You shall do pass> | |
</test> | |
</doc> | |
'''; | |
final RegExp WS_REGEX = new RegExp(r'[\r\n\t]+'); | |
main() { | |
group('Without >', () { | |
String trimmedXml; | |
setUp(() { | |
trimmedXml = xmlWithoutGt.replaceAll(WS_REGEX, ''); | |
}); | |
test('Parsing and reencoding the document should be equal', () { | |
XmlDocument document = parse(trimmedXml); | |
String reencoded = document.toXmlString().replaceAll(WS_REGEX, ''); | |
expect(trimmedXml, equalsIgnoringWhitespace(reencoded)); | |
}); | |
}); | |
group('With >', () { | |
String trimmedXml; | |
setUp(() { | |
trimmedXml = xmlWithGt.replaceAll(WS_REGEX, ''); | |
}); | |
test('Parsing and reencoding the document should be equal', () { | |
XmlDocument document = parse(trimmedXml); | |
String reencoded = document.toXmlString() | |
.replaceAll(WS_REGEX, ''); | |
expect(trimmedXml, equalsIgnoringWhitespace(reencoded)); | |
}); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment