Skip to content

Commit

Permalink
[test] added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MchKosticyn committed Jan 14, 2024
1 parent f732cb3 commit e954d4b
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 6 deletions.
5 changes: 3 additions & 2 deletions VSharp.Test/Tests/Marshaling.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using NUnit.Framework;
using System.Collections.Generic;
using ChessDotNet;
Expand Down Expand Up @@ -196,7 +197,7 @@ public static int Indirect_Change()
return x;
}

[TestSvm]
[TestSvm(100)]
public static Dictionary<char, Piece> CreateRepeatingDictionary()
{
Dictionary<char, Piece> fenMappings = new Dictionary<char, Piece>()
Expand All @@ -209,7 +210,7 @@ public static Dictionary<char, Piece> CreateRepeatingDictionary()
return fenMappings;
}

[Ignore("GetTypeFromHandle() is not implemented")]
[TestSvm(100)]
public static Dictionary<char, Piece> CreateDictionary()
{
Dictionary<char, Piece> fenMappings = new Dictionary<char, Piece>()
Expand Down
49 changes: 45 additions & 4 deletions VSharp.Test/Tests/Strings.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections;
using System.Text;
using NUnit.Framework;
using VSharp.Test;
Expand Down Expand Up @@ -339,12 +340,12 @@ public static string StringRegex1(string str)
}

[Ignore("takes too much time")]
public static string StringRegex2(string str)
public static int StringRegex2(string str)
{
var result = System.Text.RegularExpressions.Regex.Match(str, ".*");
if (result.Value != str)
return "";
return result.Value;
return -1;
return 1;
}

[TestSvm(100, strat: SearchStrategy.ExecutionTreeContributedCoverage)]
Expand All @@ -356,14 +357,54 @@ public static string StringRegex3(string str)
return result.Groups["major"].Value + result.Groups["minor"].Value + result.Groups["patch"].Value;
}

[TestSvm(100, strat: SearchStrategy.ExecutionTreeContributedCoverage)]
[TestSvm(100)]
public static string StringRegex4()
{
var input = "7.3.7";
var result = System.Text.RegularExpressions.Regex.Match(input, @"^(?<major>\d+)(\.(?<minor>\d+))?(\.(?<patch>\d+))?$");
return result.Groups["major"].Value + result.Groups["minor"].Value + result.Groups["patch"].Value;
}

[TestSvm(100)]
public static string StringRegex5()
{
var input = "kek";
var result = System.Text.RegularExpressions.Regex.Match(input, "(?<fst>)");
return result.Groups["fst"].Value;
}

[TestSvm(100)]
public static bool StringHashtable()
{
var table = new Hashtable { { "fst", 1 } };
return table.ContainsKey("fst");
}

[Ignore("fix strings comparison")]
public static int StringGetHashCode(string str)
{
if (str == "abc")
{
if (str.GetHashCode() == "abc".GetHashCode())
return 1;
return -1;
}

return 0;
}

[Ignore("takes too much time")]
public static int StringGetHashCode1(string str)
{
if (str == "abc")
{
if (str.GetHashCode() == "abc".GetHashCode())
return 1;
return -1;
}

return 0;
}
[TestSvm(100, strat: SearchStrategy.ExecutionTreeContributedCoverage)]
public static int FromUtf16(char[] a)
{
Expand Down

0 comments on commit e954d4b

Please sign in to comment.