Skip to content

Commit 6d15aa3

Browse files
committed
Unittests for invalid keys. Add ldc 0.15 to allow failures on travis
1 parent f1ecefb commit 6d15aa3

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ language: d
22
matrix:
33
allow_failures:
44
- d: gdc-4.9.2
5+
- d: ldc-0.15.1
56
include:
67
- d: dmd-2.069.2
78
env: USE_DOVERALLS=true

source/mimeapps.d

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -624,6 +624,15 @@ Key=Value`;
624624
assert(mimeAppsList.addedAssociations().appsForMimeType("text/plain").equal(["geany.desktop", "kde4-kwrite.desktop"]));
625625
assert(mimeAppsList.removedAssociations().appsForMimeType("text/plain").equal(["libreoffice-writer.desktop"]));
626626
assert(mimeAppsList.defaultApplications().appsForMimeType("x-scheme-handler/http").equal(["chromium.desktop", "iceweasel.desktop"]));
627+
628+
content =
629+
`[Default Applications]
630+
text/plain=geany.desktop
631+
notmimetype=value
632+
`;
633+
assertThrown!IniLikeReadException(new MimeAppsListFile(iniLikeStringReader(content)));
634+
assertNotThrown(mimeAppsList = new MimeAppsListFile(iniLikeStringReader(content), null, IniLikeFile.ReadOptions(IniLikeGroup.InvalidKeyPolicy.save)));
635+
assert(mimeAppsList.defaultApplications().value("notmimetype") == "value");
627636
}
628637

629638
/**
@@ -665,7 +674,7 @@ final class MimeInfoCacheFile : IniLikeFile
665674
*/
666675
this(IniLikeReader)(IniLikeReader reader, string fileName = null, ReadOptions readOptions = ReadOptions.init)
667676
{
668-
super(reader, fileName);
677+
super(reader, fileName, readOptions);
669678
_mimeCache = cast(MimeAppsGroup)group("MIME Cache");
670679
enforce(_mimeCache !is null, new IniLikeReadException("No \"MIME Cache\" group", 0));
671680
}
@@ -721,6 +730,8 @@ text/plain=geany.desktop;
721730
notmimetype=value
722731
`;
723732
assertThrown!IniLikeReadException(new MimeInfoCacheFile(iniLikeStringReader(content)));
733+
assertNotThrown(mimeInfoCache = new MimeInfoCacheFile(iniLikeStringReader(content), null, IniLikeFile.ReadOptions(IniLikeGroup.InvalidKeyPolicy.save)));
734+
assert(mimeInfoCache.value("notmimetype") == "value");
724735
}
725736

726737
/**
@@ -1101,7 +1112,7 @@ struct AssociationUpdateQuery
11011112
/**
11021113
* Apply query to MimeAppsListFile.
11031114
*/
1104-
void apply(MimeAppsListFile file) const
1115+
@safe void apply(MimeAppsListFile file) const
11051116
{
11061117
foreach(op; _operations)
11071118
{
@@ -1147,7 +1158,7 @@ unittest
11471158
* Apply query for file with fileName. This should be mimeapps.list file.
11481159
* If file does not exist it will be created.
11491160
*/
1150-
void updateAssociations(string fileName, ref AssociationUpdateQuery query)
1161+
@trusted void updateAssociations(string fileName, ref AssociationUpdateQuery query)
11511162
{
11521163
MimeAppsListFile file;
11531164
if (fileName.exists) {
@@ -1169,7 +1180,7 @@ static if (isFreedesktop)
11691180
* Developer can't guarantee yet that it will not damage your file associations settings.
11701181
* Note: This function is available only on freedesktop.
11711182
*/
1172-
void updateAssociations(ref AssociationUpdateQuery query)
1183+
@safe void updateAssociations(ref AssociationUpdateQuery query)
11731184
{
11741185
foreach(fileName; writableMimeAppsListPaths()) {
11751186
updateAssociations(fileName, query);

0 commit comments

Comments
 (0)