From fdfa5701e906e6170a0ace13f65b765eb4f107aa Mon Sep 17 00:00:00 2001 From: "R.G. Esteves" Date: Fri, 20 Jul 2018 05:46:18 -0700 Subject: [PATCH] Started implementation of Maybe --- ExternalProfilerDriver/VTuneInvoker.cs | 19 +++++++++++++++++++ ExternalProfilerDriverTest/MaybeTests.cs | 17 +++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 ExternalProfilerDriverTest/MaybeTests.cs diff --git a/ExternalProfilerDriver/VTuneInvoker.cs b/ExternalProfilerDriver/VTuneInvoker.cs index 59591a2..ca42218 100644 --- a/ExternalProfilerDriver/VTuneInvoker.cs +++ b/ExternalProfilerDriver/VTuneInvoker.cs @@ -25,6 +25,25 @@ namespace ExternalProfilerDriver { + public struct Maybe + { + public readonly static Maybe None = new Maybe(); + public T Value; + public bool HasValue; + + public Maybe(T value) { + Value = value; + HasValue = true; + } + + public override string ToString() + { + if (!HasValue) { + return ""; + } + return Value.ToString(); + } + } public class VTuneInvoker { diff --git a/ExternalProfilerDriverTest/MaybeTests.cs b/ExternalProfilerDriverTest/MaybeTests.cs new file mode 100644 index 0000000..254af5d --- /dev/null +++ b/ExternalProfilerDriverTest/MaybeTests.cs @@ -0,0 +1,17 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using ExternalProfilerDriver; + +namespace ExternalProfilerDriverTest +{ + [TestClass] + public class MaybeTest + { + [TestMethod] + public void TestMaybeNone() + { + Maybe testNothing = Maybe.None; + + Assert.IsFalse(testNothing.HasValue); + } + } +}