diff options
author | 2011-05-12 17:29:39 -0700 | |
---|---|---|
committer | 2011-05-12 17:29:39 -0700 | |
commit | 694413becc0543ec425079f059542a1ebbe954e1 (patch) | |
tree | 38c2d3d36c46f5a0b1db680040de7005d6c6ac91 | |
parent | 81acbf9b3d4cc0662df9e42cf0a4eaeb99c760d3 (diff) | |
parent | 746c28cd03e8840e8525352ff2aebcfeb76ca2a1 (diff) |
Merge
-rw-r--r-- | BCT/Samples/Generics/GenericsExample.cs | 20 | ||||
-rw-r--r-- | BCT/Samples/Strings/StringsExample.cs | 20 |
2 files changed, 40 insertions, 0 deletions
diff --git a/BCT/Samples/Generics/GenericsExample.cs b/BCT/Samples/Generics/GenericsExample.cs new file mode 100644 index 00000000..c7016ceb --- /dev/null +++ b/BCT/Samples/Generics/GenericsExample.cs @@ -0,0 +1,20 @@ +using System;
+using System.Collections.Generic;
+using System.Diagnostics.Contracts;
+using System.Linq;
+using System.Text;
+
+/* Simple example of generics/dictionary support needed by Poirot */
+class GenericsExample
+{
+ public static void Main()
+ {
+ Dictionary<String, String> dict = new Dictionary<String, String>();
+ dict["foo"] = "bar";
+ Contract.Assert(dict.ContainsKey("foo"));
+ Contract.Assert(dict.ContainsValue("bar"));
+ Contract.Assert(dict["foo"] == "bar");
+ dict.Remove("foo");
+ Contract.Assert(dict["foo"] == "bar"); // should fail
+ }
+}
\ No newline at end of file diff --git a/BCT/Samples/Strings/StringsExample.cs b/BCT/Samples/Strings/StringsExample.cs new file mode 100644 index 00000000..a04fc9a0 --- /dev/null +++ b/BCT/Samples/Strings/StringsExample.cs @@ -0,0 +1,20 @@ +using System;
+using System.Collections.Generic;
+using System.Diagnostics.Contracts;
+using System.Linq;
+using System.Text;
+
+/* Example of string functionality needed by Poirot: concatenation and equality */
+class StringsExample
+{
+ public static void Main()
+ {
+ string foo = "delicious";
+ string bar = "cake";
+ Contract.Assert(!foo.Equals(bar));
+ string foo_bar = foo + bar;
+ Contract.Assert(foo_bar.Equals("deliciouscake"));
+ string delish = "delicious";
+ Contract.Assert(foo.Equals(delish));
+ }
+}
\ No newline at end of file |