// ------------------------------------------------------------------

// String.cs: Represents OCL testing for the String STL type

// ------------------------------------------------------------------

// Project: C# and OCL Compiler

// Module:  Testing

// Author:  Dave Arnold

// Version: 1.0

// ------------------------------------------------------------------

 

// ------------------------------------------------------------------

// Imports

// ------------------------------------------------------------------

using System;

using System.Collections;

// ------------------------------------------------------------------

 

// ------------------------------------------------------------------

// DaveArnold.OCLTesting Namespace

// ------------------------------------------------------------------

namespace DaveArnold.OCLTesting

{

       // A Class to test the String expressions

       class StringTests

       {

              OCL

              [

                     "context StringTests::_s1 : String"

                     "init: 'Hello World'"

              ]

              private string _s1;

             

              OCL

              [

                     "context StringTests::_s2 : Integer"

                     "init: 'Hello World'.size()"

              ]

              private int _s2;

             

              OCL

              [

                     "context StringTests::_s3 : String"

                     "init: 'Hello'.concat(' World')"

              ]

              private string _s3;

             

              OCL

              [

                     "context StringTests::_s4 : String"

                     "init: 'Hello World'.substring(7, 11)"

              ]

              private string _s4;

             

 

              OCL

              [

                     "context StringTests::_s5 : Integer"

                     "init: '10'.toInteger()"

              ]

              private int _s5;

             

              OCL

              [

                     "context StringTests::_s6 : Real"

                     "init: '10.34342434342'.toReal()"

              ]

              private double _s6;

             

              OCL

              [

                     "context StringTests::_s7 : Boolean"

                     "init: 'Hello' = 'Hello'"

              ]

              private bool _s7;

             

              OCL

              [

                     "context StringTests::_s8 : Boolean"

                     "init: 'Hello' <> 'Hello'"

              ]

              private bool _s8;

             

              OCL

              [

                     "context StringTests::_s9 : Boolean"

                     "init: 'Hello' = 'World'"

              ]

              private bool _s9;

             

              OCL

              [

                     "context StringTests::_s10 : Boolean"

                     "init: 'Hello' <> 'World'"

              ]

              private bool _s10;

             

              OCL

              [

                     "context StringTests::_s7a : Boolean"

                     "init: 'Hello'.=('Hello')"

              ]

              private bool _s7a;

             

              OCL

              [

                     "context StringTests::_s8a : Boolean"

                     "init: 'Hello'.<>('Hello')"

              ]

              private bool _s8a;

             

              OCL

              [

                     "context StringTests::_s9a : Boolean"

                     "init: 'Hello'.=('World')"

              ]

              private bool _s9a;

             

              OCL

              [

                     "context StringTests::_s10a : Boolean"

                     "init: 'Hello'.<>('World')"

              ]

              private bool _s10a;

             

             

              public void RunTests()

              {

                     Console.WriteLine("---------------- STRING TESTS -----------------");

                     Console.WriteLine("S1 ('Hello World'): {0}", _s1);

                     Console.WriteLine("S2 ('Hello World'.size()): {0}", _s2);

                     Console.WriteLine("S3 ('Hello'.concat(' World')): {0}", _s3);

                     Console.WriteLine("S4 ('Hello World'.substring(7, 11)): {0}", _s4);

                     Console.WriteLine("S5 ('10'.toInteger()): {0}", _s5);

                     Console.WriteLine("S6 ('10.34342432342.toReal()): {0}", _s6);

                     Console.WriteLine("S7 ('Hello' = 'Hello'): {0}", _s7);

                     Console.WriteLine("S8 ('Hello' <> 'Hello'): {0}", _s8);

                     Console.WriteLine("S9 ('Hello' = 'World'): {0}", _s9);

                     Console.WriteLine("S10 ('Hello' <> 'World'): {0}", _s10);

                     Console.WriteLine("S7a ('Hello'.=('Hello')): {0}", _s7a);

                     Console.WriteLine("S8a ('Hello'.<>('Hello')): {0}", _s8a);

                     Console.WriteLine("S9a ('Hello'.=('World')): {0}", _s9a);

                     Console.WriteLine("S10a ('Hello'.<>('World')): {0}", _s10a);

                     Console.WriteLine("------------ STRING TESTS COMPLETE ------------");

              }

       }

}

 

// ------------------------------------------------------------------

// EOF