| 1 | Unit CharUtilsUnitTests;
|
|---|
| 2 |
|
|---|
| 3 | Interface
|
|---|
| 4 |
|
|---|
| 5 | uses
|
|---|
| 6 | Classes,
|
|---|
| 7 | TestAssert,
|
|---|
| 8 | CharUtilsUnit;
|
|---|
| 9 |
|
|---|
| 10 | FUNCTION getCharUtilsUnitTests : TList;
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 | Implementation
|
|---|
| 14 |
|
|---|
| 15 | PROCEDURE testCharIsDigit_True;
|
|---|
| 16 | VAR
|
|---|
| 17 | tmpResult : boolean;
|
|---|
| 18 | BEGIN
|
|---|
| 19 | tmpResult := CharIsDigit('0');
|
|---|
| 20 | assertTrue('testCharIsDigit_True - 0', tmpResult);
|
|---|
| 21 |
|
|---|
| 22 | tmpResult := CharIsDigit('1');
|
|---|
| 23 | assertTrue('testCharIsDigit_True - 1', tmpResult);
|
|---|
| 24 |
|
|---|
| 25 | tmpResult := CharIsDigit('2');
|
|---|
| 26 | assertTrue('testCharIsDigit_True - 2', tmpResult);
|
|---|
| 27 |
|
|---|
| 28 | tmpResult := CharIsDigit('3');
|
|---|
| 29 | assertTrue('testCharIsDigit_True - 3', tmpResult);
|
|---|
| 30 |
|
|---|
| 31 | tmpResult := CharIsDigit('4');
|
|---|
| 32 | assertTrue('testCharIsDigit_True - 4', tmpResult);
|
|---|
| 33 |
|
|---|
| 34 | tmpResult := CharIsDigit('5');
|
|---|
| 35 | assertTrue('testCharIsDigit_True - 5', tmpResult);
|
|---|
| 36 |
|
|---|
| 37 | tmpResult := CharIsDigit('6');
|
|---|
| 38 | assertTrue('testCharIsDigit_True - 6', tmpResult);
|
|---|
| 39 |
|
|---|
| 40 | tmpResult := CharIsDigit('7');
|
|---|
| 41 | assertTrue('testCharIsDigit_True - 7', tmpResult);
|
|---|
| 42 |
|
|---|
| 43 | tmpResult := CharIsDigit('8');
|
|---|
| 44 | assertTrue('testCharIsDigit_True - 8', tmpResult);
|
|---|
| 45 |
|
|---|
| 46 | tmpResult := CharIsDigit('9');
|
|---|
| 47 | assertTrue('testCharIsDigit_True - 9', tmpResult);
|
|---|
| 48 | END;
|
|---|
| 49 |
|
|---|
| 50 |
|
|---|
| 51 | PROCEDURE testCharIsDigit_False;
|
|---|
| 52 | VAR
|
|---|
| 53 | tmpResult : boolean;
|
|---|
| 54 | BEGIN
|
|---|
| 55 | tmpResult := CharIsDigit('/');
|
|---|
| 56 | assertFalse('testCharIsDigit_False - /', tmpResult);
|
|---|
| 57 |
|
|---|
| 58 | tmpResult := CharIsDigit(':');
|
|---|
| 59 | assertFalse('testCharIsDigit_False - :', tmpResult);
|
|---|
| 60 |
|
|---|
| 61 | tmpResult := CharIsDigit(CharTAB);
|
|---|
| 62 | assertFalse('testCharIsDigit_False - CharTAB', tmpResult);
|
|---|
| 63 |
|
|---|
| 64 | tmpResult := CharIsDigit('a');
|
|---|
| 65 | assertFalse('testCharIsDigit_False - a', tmpResult);
|
|---|
| 66 |
|
|---|
| 67 | tmpResult := CharIsDigit('z');
|
|---|
| 68 | assertFalse('testCharIsDigit_False - z', tmpResult);
|
|---|
| 69 |
|
|---|
| 70 | tmpResult := CharIsDigit('A');
|
|---|
| 71 | assertFalse('testCharIsDigit_False - A', tmpResult);
|
|---|
| 72 |
|
|---|
| 73 | tmpResult := CharIsDigit('Z');
|
|---|
| 74 | assertFalse('testCharIsDigit_False - Z', tmpResult);
|
|---|
| 75 |
|
|---|
| 76 | tmpResult := CharIsDigit(#127);
|
|---|
| 77 | assertFalse('testCharIsDigit_False - #127', tmpResult);
|
|---|
| 78 |
|
|---|
| 79 | tmpResult := CharIsDigit(#255);
|
|---|
| 80 | assertFalse('testCharIsDigit_False - #255', tmpResult);
|
|---|
| 81 |
|
|---|
| 82 | END;
|
|---|
| 83 |
|
|---|
| 84 |
|
|---|
| 85 | // ----------------------------------------------------------
|
|---|
| 86 |
|
|---|
| 87 |
|
|---|
| 88 | PROCEDURE testCharIsAlpha_True;
|
|---|
| 89 | VAR
|
|---|
| 90 | tmpResult : boolean;
|
|---|
| 91 | BEGIN
|
|---|
| 92 | tmpResult := CharIsAlpha('A');
|
|---|
| 93 | assertTrue('testCharIsAlpha_True - A', tmpResult);
|
|---|
| 94 |
|
|---|
| 95 | tmpResult := CharIsAlpha('B');
|
|---|
| 96 | assertTrue('testCharIsAlpha_True - B', tmpResult);
|
|---|
| 97 |
|
|---|
| 98 | tmpResult := CharIsAlpha('X');
|
|---|
| 99 | assertTrue('testCharIsAlpha_True - X', tmpResult);
|
|---|
| 100 |
|
|---|
| 101 | tmpResult := CharIsAlpha('Z');
|
|---|
| 102 | assertTrue('testCharIsAlpha_True - Z', tmpResult);
|
|---|
| 103 |
|
|---|
| 104 | tmpResult := CharIsAlpha('a');
|
|---|
| 105 | assertTrue('testCharIsAlpha_True - a', tmpResult);
|
|---|
| 106 |
|
|---|
| 107 | tmpResult := CharIsAlpha('b');
|
|---|
| 108 | assertTrue('testCharIsAlpha_True - b', tmpResult);
|
|---|
| 109 |
|
|---|
| 110 | tmpResult := CharIsAlpha('x');
|
|---|
| 111 | assertTrue('testCharIsAlpha_True - x', tmpResult);
|
|---|
| 112 |
|
|---|
| 113 | tmpResult := CharIsAlpha('z');
|
|---|
| 114 | assertTrue('testCharIsAlpha_True - z', tmpResult);
|
|---|
| 115 |
|
|---|
| 116 | END;
|
|---|
| 117 |
|
|---|
| 118 |
|
|---|
| 119 | PROCEDURE testCharIsAlpha_False;
|
|---|
| 120 | VAR
|
|---|
| 121 | tmpResult : boolean;
|
|---|
| 122 | BEGIN
|
|---|
| 123 | tmpResult := CharIsAlpha('@');
|
|---|
| 124 | assertFalse('testCharIsAlpha_False - @', tmpResult);
|
|---|
| 125 |
|
|---|
| 126 | tmpResult := CharIsAlpha('[');
|
|---|
| 127 | assertFalse('testCharIsAlpha_False - [', tmpResult);
|
|---|
| 128 |
|
|---|
| 129 | tmpResult := CharIsAlpha(#140);
|
|---|
| 130 | assertFalse('testCharIsAlpha_False - #140', tmpResult);
|
|---|
| 131 |
|
|---|
| 132 | tmpResult := CharIsAlpha('{');
|
|---|
| 133 | assertFalse('testCharIsAlpha_False - {', tmpResult);
|
|---|
| 134 |
|
|---|
| 135 | END;
|
|---|
| 136 |
|
|---|
| 137 |
|
|---|
| 138 | // ----------------------------------------------------------
|
|---|
| 139 |
|
|---|
| 140 |
|
|---|
| 141 | FUNCTION getCharUtilsUnitTests : TList;
|
|---|
| 142 | BEGIN
|
|---|
| 143 | result := TList.Create;
|
|---|
| 144 |
|
|---|
| 145 | result.add(@testCharIsDigit_True);
|
|---|
| 146 | result.add(@testCharIsDigit_False);
|
|---|
| 147 |
|
|---|
| 148 | result.add(@testCharIsAlpha_True);
|
|---|
| 149 | result.add(@testCharIsAlpha_False);
|
|---|
| 150 |
|
|---|
| 151 | END;
|
|---|
| 152 |
|
|---|
| 153 | END.
|
|---|