Skip to content
This repository has been archived by the owner on Nov 22, 2023. It is now read-only.

Check dotnet format in travis #198

Merged
merged 16 commits into from
Sep 13, 2019
18 changes: 18 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
###############################
# Core EditorConfig Options #
###############################

# dotnet-format requires version 3.1.37601
# dotnet tool update -g dotnet-format
# remember to have: git config --global core.autocrlf false #(which is usually default)

root = true

# Every file

[*]
insert_final_newline = true
trim_trailing_whitespace = true
charset = utf-8
end_of_line = lf
#indent_style = tab # TODO
erikzhang marked this conversation as resolved.
Show resolved Hide resolved
9 changes: 7 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,17 @@ dotnet: 2.2.300
before_install:
- cd tests/neo-vm.Tests
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then ulimit -n 2048; fi

install:
- dotnet tool install -g dotnet-format --version 4.0.40103 --add-source https://dotnet.myget.org/F/format/api/v3/index.json
- export PATH="$PATH:$HOME/.dotnet/tools"
- dotnet-format --version
before_script:
- echo "Checking format..."
- dotnet format --check --dry-run -w . -v diagnostic # check C# formatting for neo.sln
script:
- dotnet restore
- find * -name *.csproj | xargs -I % dotnet add % package coverlet.msbuild
- dotnet test /p:CollectCoverage=true /p:CoverletOutputFormat=opencover

after_success:
# After all tests OK, Send CodeDov report
- echo "Test Success - Branch($TRAVIS_BRANCH) Pull Request($TRAVIS_PULL_REQUEST) Tag($TRAVIS_TAG)"
Expand Down
2 changes: 1 addition & 1 deletion src/neo-vm/OpCode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ public enum OpCode : byte

//Reserved = 0xAC,
//Reserved = 0xAE,

// Array
/// <summary>
/// An array is removed from top of the main stack. Its size is put on top of the main stack.
Expand Down
2 changes: 1 addition & 1 deletion src/neo-vm/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
using System.Runtime.CompilerServices;

[assembly: InternalsVisibleTo("neo-vm.Tests")]
[assembly: InternalsVisibleTo("neo-vm.Tests")]
2 changes: 1 addition & 1 deletion src/neo-vm/RandomAccessStack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,4 @@ public void Set(int index, T item)
list[(list.Count - index - 1)] = item;
}
}
}
}
2 changes: 1 addition & 1 deletion tests/neo-vm.Tests/Converters/ScriptConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ public override void WriteJson(JsonWriter writer, object value, JsonSerializer s
}
}
}
}
}
2 changes: 1 addition & 1 deletion tests/neo-vm.Tests/Extensions/JsonExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ public static string ToJson(this object ut)
return JsonConvert.SerializeObject(ut, _settings);
}
}
}
}
2 changes: 1 addition & 1 deletion tests/neo-vm.Tests/Extensions/StringExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ public static byte[] FromHexString(this string value)
return result;
}
}
}
}
2 changes: 1 addition & 1 deletion tests/neo-vm.Tests/Helpers/RandomHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ public static short RandInt16()
return (short)_rand.Next(short.MaxValue);
}
}
}
}
2 changes: 1 addition & 1 deletion tests/neo-vm.Tests/Types/VMUT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ public class VMUT
[JsonProperty]
public VMUTEntry[] Tests { get; set; }
}
}
}
2 changes: 1 addition & 1 deletion tests/neo-vm.Tests/Types/VMUTActionType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ public enum VMUTActionType
StepOut,
StepOver,
}
}
}
2 changes: 1 addition & 1 deletion tests/neo-vm.Tests/Types/VMUTEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ public class VMUTEntry
[JsonProperty]
public VMUTStep[] Steps { get; set; }
}
}
}
2 changes: 1 addition & 1 deletion tests/neo-vm.Tests/Types/VMUTExecutionContextState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ public class VMUTExecutionContextState
[JsonProperty]
public VMUTStackItem[] EvaluationStack { get; set; }
}
}
}
2 changes: 1 addition & 1 deletion tests/neo-vm.Tests/Types/VMUTExecutionEngineState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ public class VMUTExecutionEngineState
[JsonProperty]
public VMUTExecutionContextState[] InvocationStack { get; set; }
}
}
}
2 changes: 1 addition & 1 deletion tests/neo-vm.Tests/Types/VMUTStackItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ public class VMUTStackItem
[JsonProperty]
public JToken Value { get; set; }
}
}
}
12 changes: 6 additions & 6 deletions tests/neo-vm.Tests/Types/VMUTStackItemType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,27 @@ public enum VMUTStackItemType
/// Boolean (true,false)
/// </summary>
Boolean,

/// <summary>
/// ByteArray
/// </summary>
ByteArray,

/// <summary>
/// ByteArray as UTF8 string
/// </summary>
String,

/// <summary>
/// String
/// </summary>
Interop,

/// <summary>
/// BigInteger
/// </summary>
Integer,

/// <summary>
/// Array
/// </summary>
Expand All @@ -42,4 +42,4 @@ public enum VMUTStackItemType
/// </summary>
Map
}
}
}
2 changes: 1 addition & 1 deletion tests/neo-vm.Tests/Types/VMUTStep.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ public class VMUTStep
[JsonProperty]
public VMUTExecutionEngineState Result { get; set; }
}
}
}
2 changes: 1 addition & 1 deletion tests/neo-vm.Tests/UtRandomAccessStack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,4 +147,4 @@ public void TestSet()
CollectionAssert.AreEqual(new int[] { 1, 2, 3, 4 }, stack.Select(u => u).ToArray());
}
}
}
}
2 changes: 1 addition & 1 deletion tests/neo-vm.Tests/UtScript.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,4 @@ public void Parse()
Assert.AreSame(ins, Instruction.RET);
}
}
}
}
2 changes: 1 addition & 1 deletion tests/neo-vm.Tests/UtScriptBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -211,4 +211,4 @@ public void TestEmitPushString()
}
}
}
}
}
2 changes: 1 addition & 1 deletion tests/neo-vm.Tests/UtStackItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,4 @@ public void CastTest()

}
}
}
}
104 changes: 52 additions & 52 deletions tests/neo-vm.Tests/UtUnsafe.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Neo.VM;
using System;
using Neo.VM;
using System;

namespace Neo.Test
{
[TestClass]
Expand All @@ -19,78 +19,78 @@ public void NotZero()
Assert.IsFalse(Unsafe.NotZero(new byte[0]));
Assert.IsFalse(Unsafe.NotZero(new byte[4]));
Assert.IsFalse(Unsafe.NotZero(new byte[8]));
Assert.IsFalse(Unsafe.NotZero(new byte[11]));
Assert.IsFalse(Unsafe.NotZero(new byte[11]));

Assert.IsTrue(Unsafe.NotZero(new byte[4] { 0x00, 0x00, 0x00, 0x01 }));
Assert.IsTrue(Unsafe.NotZero(new byte[8] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }));
Assert.IsTrue(Unsafe.NotZero(new byte[11] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }));
}
}

[TestMethod]
public void MemoryCopy()
{
var from = new byte[0];
var to = new byte[0];

Unsafe.MemoryCopy(from, 0, to, 0, 0);
CollectionAssert.AreEqual(from, to);
from = new byte[5] { 0x06, 0x07, 0x08, 0x08, 0x09 };
Unsafe.MemoryCopy(from, 0, to, 0, 0);
CollectionAssert.AreEqual(from, to);

from = new byte[5] { 0x06, 0x07, 0x08, 0x08, 0x09 };
to = new byte[10] { 0x01, 0x02, 0x03, 0x04, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00 };

Unsafe.MemoryCopy(from, 0, to, 5, 5);
Unsafe.MemoryCopy(from, 0, to, 5, 5);
CollectionAssert.AreEqual(to, new byte[] { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x08, 0x09 });
}
}

[TestMethod]
public void MemoryEquals()
{
var a = new byte[0];
var b = new byte[1];
Assert.IsTrue(Unsafe.MemoryEquals(null, null));
Assert.IsFalse(Unsafe.MemoryEquals(a, null));
Assert.IsFalse(Unsafe.MemoryEquals(null, a));
{
var a = new byte[0];
var b = new byte[1];

Assert.IsTrue(Unsafe.MemoryEquals(null, null));
Assert.IsFalse(Unsafe.MemoryEquals(a, null));
Assert.IsFalse(Unsafe.MemoryEquals(null, a));

Assert.IsTrue(Unsafe.MemoryEquals(a, a));
Assert.IsTrue(Unsafe.MemoryEquals(new byte[0], new byte[0]));
Assert.IsFalse(Unsafe.MemoryEquals(a, b));
a = new byte[4];
b = new byte[4];
Assert.IsFalse(Unsafe.MemoryEquals(a, b));

a = new byte[4];
b = new byte[4];
Assert.IsTrue(Unsafe.MemoryEquals(a, b));

a = new byte[8];
a = new byte[8];
b = new byte[8];
Assert.IsTrue(Unsafe.MemoryEquals(a, b));
a = new byte[11];
Assert.IsTrue(Unsafe.MemoryEquals(a, b));

a = new byte[11];
b = new byte[11];
Assert.IsTrue(Unsafe.MemoryEquals(a, b));
a = new byte[4] { 0x00, 0x00, 0x00, 0x01 };
b = new byte[4] { 0x00, 0x00, 0x00, 0x01 };
Assert.IsTrue(Unsafe.MemoryEquals(a, b));
a = new byte[4] { 0x00, 0x00, 0x00, 0x01 };
b = new byte[4] { 0x00, 0x00, 0x00, 0x02 };
Assert.IsTrue(Unsafe.MemoryEquals(a, b));

a = new byte[4] { 0x00, 0x00, 0x00, 0x01 };
b = new byte[4] { 0x00, 0x00, 0x00, 0x01 };
Assert.IsTrue(Unsafe.MemoryEquals(a, b));

a = new byte[4] { 0x00, 0x00, 0x00, 0x01 };
b = new byte[4] { 0x00, 0x00, 0x00, 0x02 };
Assert.IsFalse(Unsafe.MemoryEquals(a, b));

a = new byte[8] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 };
a = new byte[8] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 };
b = new byte[8] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 };
Assert.IsTrue(Unsafe.MemoryEquals(a, b));
a = new byte[8] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 };
Assert.IsTrue(Unsafe.MemoryEquals(a, b));

a = new byte[8] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 };
b = new byte[8] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02 };
Assert.IsFalse(Unsafe.MemoryEquals(a, b));
a = new byte[11] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 };
Assert.IsFalse(Unsafe.MemoryEquals(a, b));

a = new byte[11] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 };
b = new byte[11] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 };
Assert.IsTrue(Unsafe.MemoryEquals(a, b));
a = new byte[11] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 };
Assert.IsTrue(Unsafe.MemoryEquals(a, b));

a = new byte[11] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 };
b = new byte[11] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02 };
Assert.IsFalse(Unsafe.MemoryEquals(a, b));
}
}
}
Assert.IsFalse(Unsafe.MemoryEquals(a, b));
}
}
}
2 changes: 1 addition & 1 deletion tests/neo-vm.Tests/UtVMJson.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ private void TestJson(string path)
}
}
}
}
}
2 changes: 1 addition & 1 deletion tests/neo-vm.Tests/VMJsonTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -253,4 +253,4 @@ private void AssertAreEqual(object a, object b, string message)
}
}
}
}
}