Dear All,

Greetings!

I has been an hour I starting making my hands dirty with D. I wrote following program:

import std.string;
import std.stdio;

ushort adder(ushort a, ushort b) {
   return (cast(ushort)(a + b)) ;
}

unittest {

   bool testStimEq(ushort a, ushort b, ushort result){

      try {
         writefln(" STIM :: Testing for  %d  and  %d", a,b);
         assert(adder(a,b) == result);
         writefln(" STAT :: Test for  %d  and  %d passed", a,b);
         return (false) ;
      } catch (core.exception.AssertError) {
         writefln(" STAT :: Test for  %d  and  %d failed", a,b);
         return(true) ;
      }

   }

   bool testStimnEq(ushort a, ushort b, ushort result){

      try {
         writefln(" STIM :: Testing for  %d  and  %d", a,b);
         assert(adder(a,b) != result);
         writefln(" STAT :: Test for  %d  and  %d passed", a,b);
         return (false) ;
      } catch (core.exception.AssertError) {
         writefln(" STAT :: Test for  %d  and  %d failed", a,b);
         return(true) ;
      }

   }

   writeln(" MESG :: Starting unit testing");

   int status = 0 ;

   //status += testStimEq(1,1,2);
   //status += testStimnEq(1,10,3);

   for (ushort i = 0 ; i < 65536 ; ++i){ // Holy King-Kong!

      for (ushort j = 0 ; j < 65536 ; ++j){

         status += testStimEq(i,j,cast(ushort)(i+j));

      }
   }

   if(status == 0) writeln(" MESG :: All unit tests passed");
   else            writeln(" ERRN :: Unit test failed");

}

void main()
   {}

I found that inner for loop is behaving correctly, but i is not changing.
What is that I am doing ? OR is it gcd ?

Regards, Sumit

Reply via email to