Skip to content

Commit 54aaa47

Browse files
committed
Minor test coverage improvements
1 parent 0aa25a8 commit 54aaa47

File tree

4 files changed

+6
-2
lines changed

4 files changed

+6
-2
lines changed

fNbt.Test/CompoundTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ public void GettersAndSetters() {
107107
Assert.Throws<InvalidOperationException>(() => nestedInt[0] = nestedInt);
108108

109109
// Trying to use string indexers on non-NbtCompound tags
110+
Assert.Throws<InvalidOperationException>(() => dummyTag = childList["test"]);
110111
Assert.Throws<InvalidOperationException>(() => childList["test"] = nestedInt);
111112
Assert.Throws<InvalidOperationException>(() => nestedInt["test"] = nestedInt);
112113

fNbt.Test/NbtFileTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ public void ReadRootTag() {
233233

234234
void ReadRootTagInternal(String fileName, NbtCompression compression) {
235235
Assert.Throws<ArgumentOutOfRangeException>(() => NbtFile.ReadRootTagName(fileName, compression, true, -1));
236+
Assert.Throws<ArgumentOutOfRangeException>(() => NbtFile.ReadRootTagName(fileName, (NbtCompression)255, true, 0));
236237

237238
Assert.AreEqual("Level", NbtFile.ReadRootTagName(fileName));
238239
Assert.AreEqual("Level", NbtFile.ReadRootTagName(fileName, compression, true, 0));

fNbt.Test/NbtReaderTests.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,9 @@ public void ReadToDescendantTest() {
290290
// Ensure ReadToDescendant returns false when at end-of-stream
291291
while (reader.ReadToFollowing()) { }
292292
Assert.IsFalse(reader.ReadToDescendant("*"));
293+
294+
// Ensure that this works even on the root
295+
Assert.IsFalse(new NbtReader(TestFiles.MakeReaderTest()).ReadToDescendant("*"));
293296
}
294297

295298

fNbt/NbtFile.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -501,8 +501,7 @@ public long SaveToStream([NotNull] Stream stream, NbtCompression compression) {
501501
RootTag.WriteTag(writer);
502502
break;
503503

504-
default:
505-
throw new ArgumentOutOfRangeException("compression");
504+
// Can't be AutoDetect or unknown: parameter is already validated
506505
}
507506

508507
if (stream.CanSeek) {

0 commit comments

Comments
 (0)