products/sources/formale Sprachen/VDM/VDMPP/SSlibE2PP image not shown  

Quellcode-Bibliothek

© Kompilation durch diese Firma

[Weder Korrektheit noch Funktionsfähigkeit der Software werden zugesichert.]

Datei: StringT.vdmpp   Sprache: VDM

Original von: VDM©

class StringT is subclass of TestDriver 
functions
public tests : () -> seq of TestCase
tests () == 
 [
 new StringT01(), new StringT02(), 
 new StringT03(), new StringT04(),
 new StringT05(), new StringT06(),
 new StringT07(), new StringT08(),
 new StringT09(), -- new StringT10(),
 new StringT11(), new StringT12(),
 new StringT13(), new StringT14()
 ];
end StringT

class StringT01 is subclass of TestCase
operations 
protected test: () ==> bool
test() == 
 let c = new Character() in
 return
  (
  c.isDigit('0') = true and
  c.isDigit('1') = true and
  c.isDigit('2') = true and
  c.isDigit('3') = true and
  c.isDigit('4') = true and
  c.isDigit('5') = true and
  c.isDigit('6') = true and
  c.isDigit('7') = true and
  c.isDigit('8') = true and
  c.isDigit('9') = true and
  c.isDigit('a') = false and
  c.asDigit('0') = 0 and
  c.asDigit('1') = 1 and
  c.asDigit('2') = 2 and
  c.asDigit('3') = 3 and
  c.asDigit('4') = 4 and
  c.asDigit('5') = 5 and
  c.asDigit('6') = 6 and
  c.asDigit('7') = 7 and
  c.asDigit('8') = 8 and
  c.asDigit('9') = 9 and
  c.asDigit('a') = false )
;
protected setUp: () ==> ()
setUp() == TestName := "StringT01:\tConvert digit to integer.";
protected tearDown: () ==> ()
tearDown() == return;
end StringT01

class StringT02 is subclass of TestCase
operations 
protected test: () ==> bool
test() == 
 let c = new Character() in
 return
  (c.asDictOrder('0') = 1 and
  c.asDictOrder('9') = 10 and
  c.asDictOrder('a') = 11 and
  c.asDictOrder('A') = 12 and
  c.asDictOrder('z') = 61 and
  c.asDictOrder('Z') = 62 and
  c.asDictOrder('\n') = 999999 and
  c.asDictOrder('\t') = 999999 )
;
protected setUp: () ==> ()
setUp() == TestName := "StringT02:\tReturn dictionary order of character.";
protected tearDown: () ==> ()
tearDown() == return;
end StringT02

class StringT03 is subclass of TestCase
operations 
protected test: () ==> bool
test() == 
 let s = new String(),
  LT = String`LT2,
  LE = String`LE2,
  GT = String`GT2,
  GE = String`GE2
 in
 return
  (s.LT("123","123") = false and
  LT("123")("123") = false and
  s.GT("123","123") = false and
  GT("123")( "123") = false and
  s.LT("","") = false and
  s.GT("","") = false and
  s.LT("","123") = true and
  s.GT("","123") = false and
  s.LT("123","") = false and
  s.GT("123",""and
  s.LT("123","1234"and
  s.GT("123","1234") = false and
  s.LT("1234","123") = false and
  s.GT("1234","123"and
  s.LT("123","223"and
  s.GT("123","223") = false and
  s.LE("123","123"and
  LE("123")("123"and
  s.GE("123","123"and
  s.LE("123","1234"and
  LE("123")("1234"and
  s.GE("123","1234") = false and
  GE("123")("1234") = false and
  s.LE("1234","123") = false and
  not LE("1234")("123"and
  s.GE("1234","123"and
  s.LE("",""and
  LE("")(""and
  Sequence`fmap[seq of charbool](LT("123"))(["123""1234""""223"]) = [falsetruefalsetrueand
  Sequence`fmap[seq of charbool](LE("123"))(["1234"""]) = [truefalseand
  Sequence`fmap[seq of charbool](GT("123"))([ "123""""23"]) = [falsetruefalseand
  Sequence`fmap[seq of charbool](GE("123"))(["1234"""]) = [falsetrue
  )
;
protected setUp: () ==> ()
setUp() == TestName := "StringT03:\tCompare magnitude of string.";
protected tearDown: () ==> ()
tearDown() == return;
end StringT03

class StringT04 is subclass of TestCase
operations 
protected test: () ==> bool
test() == 
 let s1234 = "1234",
  s = new String() in
 return
  s1234 = "1234" and
  s.isSpaces("") = true and
  s.isSpaces(" ") = true and
  s.isSpaces(" \t ") = true and
  s.isSpaces([]) = true 
;
protected setUp: () ==> ()
setUp() == TestName := "StringT04:\tCompare 2 strings is equal.";
protected tearDown: () ==> ()
tearDown() == return;
end StringT04

class StringT05 is subclass of TestCase
operations 
protected test: () ==> bool
test() == 
 let LT = Character`LT,
  GT = Character`GT,
  LE = Character`LE,
  GE = Character`GE
 in
 return
  (LT('a','a') = false and
  Character`LT2('a')('a') = false and
  GT('a','a') = false and
  Character`GT2('a')('a') = false and
  LT('1','2'and
  Character`LT2('1')('2'and
  GT('1','0'and
  Character`GT2('1')('0'and
  LT('9','a'and
  Character`LT2('9')('a'and
  GT('\n','0'and
  Character`GT2('\n')('0'and
  LE('a','0') = false and
  Character`LE2('a')('0') = false and
  GE('a','0'and
  Character`GE2('a')('0'and
  Sequence`fmap[charbool](Character`LT2('5'))("456") = [falsefalsetrue]
  )
;
protected setUp: () ==> ()
setUp() == TestName := "StringT05:\tCompare magnitude of character.";
protected tearDown: () ==> ()
tearDown() == return;
end StringT05

class StringT06 is subclass of TestCase
operations 
protected test: () ==> bool
test() == 
 let s = new String(),
  substr = String`SubStr
 in
 return
  (s.subStr("Shin Sahara",6,6) = "Sahara" and
  s.subStr("Shin Sahara",6,8) = "Sahara" and
  s.subStr("Shin Sahara",6,3) = "Sah" and
  s.subStr("Shin Sahara",1,0) = "" and
  s.subStrFill("sahara",1,3,'*') = "sah" and
  s.subStrFill("sahara",1,6,'*') = "sahara" and
  s.subStrFill("sahara",1,10,'*') = "sahara****" and
  s.subStrFill("sahara",3,4,'*') = "hara" and
  s.subStrFill("sahara",3,10,'*') = "hara******" and
  s.subStrFill("sahara",1,0,'*') = "" and
  s.subStrFill("",1,6,'*') = "******" and
  String`SubStr(6)(6)("Shin Sahara") = "Sahara" and
  substr(6)(8)("Shin Sahara") = "Sahara" and
  Sequence`fmap[seq of charseq of char](substr(6)(8))(["1234567890""12345671"]) = ["67890""671"]
  )
;
protected setUp: () ==> ()
setUp() == TestName := "StringT06:\tGet substring.";
protected tearDown: () ==> ()
tearDown() == return;
end StringT06


class StringT07 is subclass of TestCase
operations 
protected test: () ==> bool
test() == 
 return
  (String`isDigits("1234567890")  = true and
  String`asInteger("1234567890")  = 1234567890 and
  String`asInteger("")  = 0 
  )
;
protected setUp: () ==> ()
setUp() == TestName := "StringT07:\tHandling digit strings.";
protected tearDown: () ==> ()
tearDown() == return;
end StringT07

class StringT08 is subclass of TestCase
operations 
protected test: () ==> bool
test() == 
 return
  (
  String`index("1234567890",'1')  = 1 and
  String`index("1234567890",'0') = 10 and
  String`index("1234567890",'a')  = 0 and
  String`indexAll("1234567890",'1')  = {1} and
  String`indexAll("1234567890",'0') = {10} and
  String`indexAll("1234567890",'a')  = {} and 
  String`indexAll("1231567190",'1')  = {1,4,8} and 
  String`indexAll("1231567191",'1')  = {1,4,8,10} and
  String`Index('1')("1234567890")  = 1 and
  String`Index('0')("1234567890") = 10 and
  String`Index('a')("1234567890")  = 0 and
  String`IndexAll2('1')("1234567890")  = {1} and
  String`IndexAll2('0')("1234567890") = {10} and
  String`IndexAll2('a')("1234567890")  = {} and 
  String`IndexAll2('1')("1231567190")  = {1,4,8} and 
  String`IndexAll2('1')("1231567191")  = {1,4,8,10} and
  Sequence`fmap[seq of charint](String`Index('1'))(["1234567890""2345671"]) = [1, 7] and
  Sequence`fmap[seq of charset of int](String`IndexAll2('1'))(["1231567190""1231567191"]) = [{1,4,8}, {1,4,8,10}]
  )
;
protected setUp: () ==> ()
setUp() == TestName := "StringT08:\tGet first position of a character in a string.";
protected tearDown: () ==> ()
tearDown() == return;
end StringT08

class StringT09 is subclass of TestCase
operations 
protected test: () ==> bool
test() == 
 let isInclude = String`isInclude
 in
 return
  (String`isInclude("1234567890")( "abc")  = false and
  isInclude("Shin")("Shin") = true and
  isInclude("Shin")("S") = true and
  isInclude("Shin")("h") = true and
  isInclude("Shin")("n") = true
  )
;
protected setUp: () ==> ()
setUp() == TestName := "StringT09:\tIs a string the substring of another string.";
protected tearDown: () ==> ()
tearDown() == return;
end StringT09

class StringT10 is subclass of TestCase
operations 
protected test: () ==> bool
test() == 
  tixe {<RuntimeError>  |->  return true } in
  return String`isInclude("Shin Sahara")("")
;
protected setUp: () ==> ()
setUp() == TestName := "StringT10:\tIs a string the substring of another string. In case of pre-condition error";
protected tearDown: () ==> ()
tearDown() == return;
end StringT10

class StringT11 is subclass of TestCase
operations 
public test: () ==> bool
test() == 
 return 
  let 区切り文字 = elems "\t\n " in
  String`GetToken("sahara\tshin", 区切り文字) = "sahara" and
  String`GetToken("sahara\tshin SCSK", 区切り文字) = "sahara" and
  String`DropToken("sahara\tshin", 区切り文字) = "\tshin" and
  String`DropToken("sahara\tshin SCSK", 区切り文字) = "\tshin SCSK" and
  String`DropToken("sahara\tshin SCSK\n", 区切り文字) = "\tshin SCSK\n"
;
protected setUp: () ==> ()
setUp() == TestName := "StringT11:\t指定した文字列の先頭tokenを得る。";
protected tearDown: () ==> ()
tearDown() == return;
end StringT11

/*
シナリオID
文字列を行に分解するシナリオ
内容
文字列を行に分解するかを検査する。
*/

class StringT12 is subclass of TestCase
operations 
public test: () ==> bool
test() == 
 return 
  let 対象文字列1 = "private 次状態を得る : () ==> 「状態」\n次状態を得る(aガード, aガード引数, aイベント, aイベント引数, a処理時間) == (\ncases mk_(aガード, 現在状態, aイベント) :\n\tmk_(-,-,(エラー検知)) -> return エラー中,\n",
   ss1 = String`getLines(対象文字列1),
   対象文字列2 = "佐原\n伸",
   ss2 = String`getLines(対象文字列2)
  in
  ss1(1) = "private 次状態を得る : () ==> 「状態」" and
  ss1(2) = "次状態を得る(aガード, aガード引数, aイベント, aイベント引数, a処理時間) == (" and
  ss1(3) = "cases mk_(aガード, 現在状態, aイベント) :" and
  ss1(4) = "\tmk_(-,-,(エラー検知)) -> return エラー中," and
  ss2(1) = "佐原" and
  ss2(2) = "伸"
;
protected setUp: () ==> ()
setUp() == TestName := "StringT12:\t文字列を行に分解する。";
protected tearDown: () ==> ()
tearDown() == return;
end StringT12

/*
シナリオID
英数字か判定するシナリオ
内容
英数字か判定が正しいかを検査する。
*/

class StringT13 is subclass of TestCase
operations 
public test: () ==> bool
test() == 
 return 
  let w英字列 = "aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ",
   w数字列 = "0123456789",
   w英数字列 = w英字列 ^ w数字列
  in
  String`isLetters(w英字列) and
  not String`isLetters(" " ^ w英字列) and
  String`isDigits(w数字列) and
  not String`isDigits(" " ^ w数字列) and
  not String`isDigits("a" ^ w数字列) and
  String`isLetterOrDigits(w英数字列)  and
  not String`isLetterOrDigits(w英数字列 ^ " "
;
protected setUp: () ==> ()
setUp() == TestName := "StringT13:\t英数字かの判定が正しいかを検査する。";
protected tearDown: () ==> ()
tearDown() == return;
end StringT13

class StringT14 is subclass of TestCase
operations 
protected test: () ==> bool
test() == 
 let isSomeString = String`isSomeString
 in return 
  isSomeString(Character`isLetterOrDigit)("007isTheMmurder"and
  not isSomeString(Character`isLetterOrDigit)("007 is the mmurder"and
  isSomeString(Character`isCapitalLetter)("SAHARA"and
  not isSomeString(Character`isCapitalLetter)("Sahara"and
  isSomeString(Character`isLowercaseLetter)("sahara"and
  not isSomeString(Character`isLowercaseLetter)("Sahara"
  
;
protected setUp: () ==> ()
setUp() == TestName := "StringT11:\tIs a some kind of string?";
protected tearDown: () ==> ()
tearDown() == return;
end StringT14


¤ Dauer der Verarbeitung: 0.4 Sekunden  (vorverarbeitet)  ¤





Kontakt
Drucken
Kontakt
sprechenden Kalenders

in der Quellcodebibliothek suchen




schauen Sie vor die Tür

Fenster


Die Firma ist wie angegeben erreichbar.

Die farbliche Syntaxdarstellung ist noch experimentell.


Bot Zugriff