summaryrefslogtreecommitdiff
path: root/BCT/Samples
diff options
context:
space:
mode:
authorGravatar 10shb <unknown>2011-05-12 09:56:11 +0530
committerGravatar 10shb <unknown>2011-05-12 09:56:11 +0530
commit746c28cd03e8840e8525352ff2aebcfeb76ca2a1 (patch)
treef09450daf5427605cdfe60d42bc7aac78f422278 /BCT/Samples
parenta1affe2114ae22816cf72d14fb4ae357a64fe7f2 (diff)
added examples of generics and string support needed by Poirot
Diffstat (limited to 'BCT/Samples')
-rw-r--r--BCT/Samples/Generics/GenericsExample.cs20
-rw-r--r--BCT/Samples/Strings/StringsExample.cs20
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