Skip to content

Commit

Permalink
Started implementation of Maybe
Browse files Browse the repository at this point in the history
  • Loading branch information
rgesteve committed Jul 20, 2018
1 parent 25f20c2 commit fdfa570
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
19 changes: 19 additions & 0 deletions ExternalProfilerDriver/VTuneInvoker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,25 @@

namespace ExternalProfilerDriver
{
public struct Maybe<T>
{
public readonly static Maybe<T> None = new Maybe<T>();
public T Value;
public bool HasValue;

public Maybe(T value) {
Value = value;
HasValue = true;
}

public override string ToString()
{
if (!HasValue) {
return "<None>";
}
return Value.ToString();
}
}

public class VTuneInvoker
{
Expand Down
17 changes: 17 additions & 0 deletions ExternalProfilerDriverTest/MaybeTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using ExternalProfilerDriver;

namespace ExternalProfilerDriverTest
{
[TestClass]
public class MaybeTest
{
[TestMethod]
public void TestMaybeNone()
{
Maybe<string> testNothing = Maybe<string>.None;

Assert.IsFalse(testNothing.HasValue);
}
}
}

0 comments on commit fdfa570

Please sign in to comment.