Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Problems.GrammaticalOptimization/DynamicDataDisplay/Common/Auxiliary/Verify.cs @ 13749

Last change on this file since 13749 was 12503, checked in by aballeit, 9 years ago

#2283 added GUI and charts; fixed MCTS

File size: 1.4 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using System.Diagnostics;
6
7namespace Microsoft.Research.DynamicDataDisplay.Common.Auxiliary
8{
9  internal static class Verify
10  {
11    [DebuggerStepThrough]
12    public static void IsTrue(this bool condition)
13    {
14      if (!condition)
15      {
16        throw new ArgumentException(Strings.Exceptions.AssertionFailedSearch);
17      }
18    }
19
20    [DebuggerStepThrough]
21    public static void IsTrue(this bool condition, string paramName)
22    {
23      if (!condition)
24      {
25        throw new ArgumentException(Strings.Exceptions.AssertionFailedSearch, paramName);
26      }
27    }
28
29    public static void IsTrueWithMessage(this bool condition, string message)
30    {
31      if (!condition)
32        throw new ArgumentException(message);
33    }
34
35    [DebuggerStepThrough]
36    public static void AssertNotNull(object obj)
37    {
38      Verify.IsTrue(obj != null);
39    }
40
41    public static void VerifyNotNull(this object obj, string paramName)
42    {
43      if (obj == null)
44        throw new ArgumentNullException(paramName);
45    }
46
47    public static void VerifyNotNull(this object obj)
48    {
49      VerifyNotNull(obj, "value");
50    }
51
52    [DebuggerStepThrough]
53    public static void AssertIsNotNaN(this double d)
54    {
55      Verify.IsTrue(!Double.IsNaN(d));
56    }
57
58    [DebuggerStepThrough]
59    public static void AssertIsFinite(this double d)
60    {
61      Verify.IsTrue(!Double.IsInfinity(d) && !(Double.IsNaN(d)));
62    }
63  }
64}
Note: See TracBrowser for help on using the repository browser.