-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #38 from JimmyCushnie/cool-upgrades
Proper error messages + other polish
- Loading branch information
Showing
26 changed files
with
1,101 additions
and
383 deletions.
There are no files selected for viewing
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
129 changes: 129 additions & 0 deletions
129
SUCC.Tests/Invalid file structure tests/InvalidFileStructureTests.cs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using SUCC.MemoryFiles; | ||
|
||
namespace SUCC.Tests | ||
{ | ||
[TestClass] | ||
public class InvalidFileStructureTests | ||
{ | ||
[TestMethod] | ||
public void InvalidFileStructure_NoKeyValue() | ||
{ | ||
const string fileText = @" | ||
this line doesn't have a colon to indicate key/value | ||
"; | ||
TestUtilities.PerformInvalidFileStructureTest(fileText); | ||
} | ||
|
||
[TestMethod] | ||
public void InvalidFileStructure_DuplicateTopLevelKeys() | ||
{ | ||
const string fileText = @" | ||
key: value | ||
key: value2 | ||
"; | ||
TestUtilities.PerformInvalidFileStructureTest(fileText); | ||
} | ||
|
||
[TestMethod] | ||
public void InvalidFileStructure_DuplicateNestedKeys() | ||
{ | ||
const string fileText = @" | ||
key: | ||
key2: lol | ||
key2: cum | ||
"; | ||
TestUtilities.PerformInvalidFileStructureTest(fileText); | ||
} | ||
|
||
[TestMethod] | ||
public void InvalidFileStructure_MismatchedSiblingIndents_Back() | ||
{ | ||
const string fileText = @" | ||
key: | ||
key2: lol | ||
key3: cum | ||
"; | ||
TestUtilities.PerformInvalidFileStructureTest(fileText); | ||
} | ||
|
||
[TestMethod] | ||
public void InvalidFileStructure_MismatchedSiblingIndents_Forward() | ||
{ | ||
const string fileText = @" | ||
key: | ||
key2: lol | ||
key3: cum | ||
"; | ||
TestUtilities.PerformInvalidFileStructureTest(fileText); | ||
} | ||
|
||
[TestMethod] | ||
public void InvalidFileStructure_TopLevelListNodes() | ||
{ | ||
const string fileText = @" | ||
key: value | ||
Key2: value2 | ||
key3: | ||
- regular | ||
- list | ||
- floating list node | ||
"; | ||
TestUtilities.PerformInvalidFileStructureTest(fileText); | ||
} | ||
|
||
|
||
|
||
[TestMethod] | ||
public void InvalidFileStructure_MultiLineString_NoBody() | ||
{ | ||
const string fileText = @" | ||
key: """""" | ||
key2: value | ||
"; | ||
TestUtilities.PerformInvalidFileStructureTest(fileText); | ||
} | ||
|
||
[TestMethod] | ||
public void InvalidFileStructure_MultiLineString_MissingTerminator() | ||
{ | ||
const string fileText = @" | ||
key: """""" | ||
multi-line string | ||
but it doesn't have a terminator! | ||
fuck! | ||
key2: value | ||
"; | ||
TestUtilities.PerformInvalidFileStructureTest(fileText); | ||
} | ||
|
||
[TestMethod] | ||
public void InvalidFileStructure_MultiLineString_MismatchedBodyIndents() | ||
{ | ||
const string fileText = @" | ||
key: """""" | ||
multi-line string | ||
but the indents are screwy | ||
fuck! | ||
"""""" | ||
"; | ||
TestUtilities.PerformInvalidFileStructureTest(fileText); | ||
} | ||
|
||
[TestMethod] | ||
public void InvalidFileStructure_MultiLineString_MismatchedTerminatorIndent() | ||
{ | ||
const string fileText = @" | ||
key: """""" | ||
multi-line string | ||
but the terminator indent is | ||
fuck! | ||
"""""" | ||
"; | ||
TestUtilities.PerformInvalidFileStructureTest(fileText); | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using SUCC.MemoryFiles; | ||
|
||
namespace SUCC.Tests | ||
{ | ||
[TestClass] | ||
public class InvalidArrayDataTests | ||
{ | ||
[TestMethod] | ||
public void InvalidFileData_InvalidArrayData_NodeHasValue() | ||
{ | ||
const string fileText = @" | ||
data: lol this isn't an int array | ||
"; | ||
TestUtilities.PerformParsingErrorTest<int[]>(fileText); | ||
} | ||
|
||
[TestMethod] | ||
public void InvalidFileData_InvalidArrayData_InvalidListItemNode() | ||
{ | ||
const string fileText = @" | ||
data: | ||
- 0 | ||
- 1 | ||
- cum | ||
- 69 | ||
"; | ||
TestUtilities.PerformParsingErrorTest<int[]>(fileText); | ||
} | ||
|
||
[TestMethod] | ||
public void InvalidFileData_InvalidArrayData_InvalidNestedCollection() | ||
{ | ||
const string fileText = @" | ||
data: | ||
- 22 | ||
- 121 | ||
- | ||
- 55 | ||
- 6969 | ||
- 11 | ||
"; | ||
TestUtilities.PerformParsingErrorTest<int[]>(fileText); | ||
} | ||
|
||
[TestMethod] | ||
public void InvalidFileData_InvalidArrayData_InvalidKeyChildren() | ||
{ | ||
const string fileText = @" | ||
data: | ||
child: node | ||
"; | ||
TestUtilities.PerformParsingErrorTest<int[]>(fileText); | ||
} | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
SUCC.Tests/Parsing error tests/InvalidBaseTypeNodeDataTests.cs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using SUCC.MemoryFiles; | ||
|
||
namespace SUCC.Tests | ||
{ | ||
[TestClass] | ||
public class InvalidBaseTypeNodeDataTests | ||
{ | ||
[TestMethod] | ||
public void InvalidFileData_InvalidBaseType_InvalidNodeValue() | ||
{ | ||
const string fileText = @" | ||
data: notanint | ||
"; | ||
TestUtilities.PerformParsingErrorTest<int>(fileText); | ||
} | ||
|
||
[TestMethod] | ||
public void InvalidFileData_InvalidBaseType_BadSpecialStringCase() | ||
{ | ||
const string fileText = @" | ||
data: """""" | ||
lmao it's a string | ||
"""""" | ||
"; | ||
TestUtilities.PerformParsingErrorTest<int>(fileText); | ||
} | ||
} | ||
} |
87 changes: 87 additions & 0 deletions
87
SUCC.Tests/Parsing error tests/InvalidComplexTypeDataTests.cs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using SUCC.MemoryFiles; | ||
using System.Collections.Generic; | ||
|
||
namespace SUCC.Tests | ||
{ | ||
[TestClass] | ||
public class InvalidComplexTypeDataTests | ||
{ | ||
[TestMethod] | ||
public void InvalidFileData_InvalidComplexTypeData_InvalidShortcut() | ||
{ | ||
const string fileText = @" | ||
data: this is an invalid shortcut lol | ||
"; | ||
TestUtilities.PerformParsingErrorTest<ComplexType>(fileText); | ||
} | ||
|
||
[TestMethod] | ||
public void InvalidFileData_InvalidComplexTypeData_ConstructorShortcutWithInvalidData() | ||
{ | ||
const string fileText = @" | ||
data: (0, test, cum) | ||
"; | ||
TestUtilities.PerformParsingErrorTest<ComplexType>(fileText); | ||
} | ||
|
||
[TestMethod] | ||
public void InvalidFileData_InvalidComplexTypeData_MethodShortcutWithInvalidData() | ||
{ | ||
const string fileText = @" | ||
data: MethodShortcut(cum, test, false) | ||
"; | ||
TestUtilities.PerformParsingErrorTest<ComplexType>(fileText); | ||
} | ||
|
||
[TestMethod] | ||
public void InvalidFileData_InvalidComplexTypeData_InvalidDataInChildren() | ||
{ | ||
const string fileText = @" | ||
data: | ||
Integer: 69 | ||
String: sex | ||
Boolean: invalid | ||
"; | ||
TestUtilities.PerformParsingErrorTest<ComplexType>(fileText); | ||
} | ||
|
||
[TestMethod] | ||
public void InvalidFileData_InvalidComplexTypeData_ChildrenAreListNodes() | ||
{ | ||
const string fileText = @" | ||
data: | ||
- lol | ||
- it's a list lol | ||
"; | ||
TestUtilities.PerformParsingErrorTest<ComplexType>(fileText); | ||
} | ||
|
||
[TestMethod] | ||
public void InvalidFileData_InvalidComplexTypeData_ChildrenAreMultiLineString() | ||
{ | ||
const string fileText = @" | ||
data: """""" | ||
this is a string haha | ||
indeed, it's a multi-line string! | ||
"""""" | ||
"; | ||
TestUtilities.PerformParsingErrorTest<ComplexType>(fileText); | ||
} | ||
|
||
|
||
const string ValidFileStructure_InvalidComplexTypeData = @" | ||
ComplexType5: | ||
- lol | ||
- it's a list lol | ||
ComplexType6: """""" | ||
this is a string haha | ||
indeed, it's a multi-line string! | ||
"""""" | ||
"; | ||
} | ||
} |
70 changes: 70 additions & 0 deletions
70
SUCC.Tests/Parsing error tests/InvalidDictionaryDataTests.cs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using SUCC.MemoryFiles; | ||
using System.Collections.Generic; | ||
|
||
namespace SUCC.Tests | ||
{ | ||
[TestClass] | ||
public class InvalidDictionaryDataTests | ||
{ | ||
[TestMethod] | ||
public void InvalidFileData_InvalidDictionaryData_NodeHasValue() | ||
{ | ||
const string fileText = @" | ||
data: lol this isn't a dictionary | ||
"; | ||
TestUtilities.PerformParsingErrorTest<Dictionary<string, int>>(fileText); | ||
} | ||
|
||
[TestMethod] | ||
public void InvalidFileData_InvalidDictionaryData_HasWrongListForChildren() | ||
{ | ||
const string fileText = @" | ||
data: | ||
- 0 | ||
- 1 | ||
- 69 | ||
"; | ||
TestUtilities.PerformParsingErrorTest<Dictionary<string, int>>(fileText); | ||
} | ||
|
||
[TestMethod] | ||
public void InvalidFileData_InvalidDictionaryData_OneInvalidValue() | ||
{ | ||
const string fileText = @" | ||
data: | ||
key: 12 | ||
key2: 35 | ||
key3: sex | ||
"; | ||
TestUtilities.PerformParsingErrorTest<Dictionary<string, int>>(fileText); | ||
} | ||
|
||
[TestMethod] | ||
public void InvalidFileData_InvalidDictionaryData_OneInvalidKey() | ||
{ | ||
const string fileText = @" | ||
data: | ||
12: value | ||
25: value2 | ||
sex: value3 | ||
"; | ||
TestUtilities.PerformParsingErrorTest<Dictionary<int, string>>(fileText); | ||
} | ||
|
||
[TestMethod] | ||
public void InvalidFileData_InvalidDictionaryData_InvalidArrayDictionary() | ||
{ | ||
const string fileText = @" | ||
data: | ||
- | ||
key: sex | ||
value: 420 | ||
- | ||
key: balls | ||
value: ass | ||
"; | ||
TestUtilities.PerformParsingErrorTest<Dictionary<string, int>>(fileText); | ||
} | ||
} | ||
} |
Oops, something went wrong.