diff options
-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 |