IDENTIFICATION DIVISION. PROGRAM-ID. strings. DATA DIVISION. WORKING-STORAGE SECTION. 77 ws-0 PIC X(30) VALUE 'SSalut tout le monde'. 77 ws-1 PIC X(10) VALUE 'Aurevoir'. 77 ws-2 PIC X(40). 01 ws-words. 05 ws-words1 PIC X(6). 05 ws-words2 PIC X(4). 05 ws-words3 PIC X(2). 05 ws-words4 PIC X(5). 05 ws-words5 PIC X(8). 77 t-count PIC 99 VALUE 01. 77 ws-count PIC 99 VALUE 00. 77 t-title PIC X(30). 77 t-exp PIC X(30). 77 t-got PIC X(30). PROCEDURE DIVISION. main-section. INSPECT ws-0 TALLYING ws-count FOR ALL CHARACTERS. MOVE 'inspect tallying for characters' to t-title. MOVE 30 TO t-exp. MOVE ws-count TO t-got. PERFORM test-section. INSPECT ws-0 TALLYING ws-count FOR ALL 'u'. MOVE 'inspect tallying for all u' to t-title. MOVE 02 TO t-exp. MOVE ws-count TO t-got. PERFORM test-section. INSPECT ws-0 TALLYING ws-count FOR LEADING 'S'. MOVE 'inspect tallying for all leading s' to t-title. MOVE 02 TO t-exp. MOVE ws-count TO t-got. PERFORM test-section. INSPECT ws-0 TALLYING ws-count FOR CHARACTERS BEFORE INITIAL SPACE. MOVE 'inspect tallying before initial space' to t-title. MOVE 06 TO t-exp. MOVE ws-count TO t-got. PERFORM test-section. INSPECT ws-0 TALLYING ws-count FOR ALL 't' BEFORE INITIAL SPACE. MOVE 'inspect tallying before initial space (2)' to t-title. MOVE 01 TO t-exp. MOVE ws-count TO t-got. PERFORM test-section. INSPECT ws-0 TALLYING ws-count FOR ALL 't' AFTER INITIAL SPACE. MOVE 'inspect tallying after initial space' to t-title. MOVE 02 TO t-exp. MOVE ws-count TO t-got. PERFORM test-section. INSPECT ws-0 REPLACING LEADING 'S' by 's'. MOVE 'inspect replacing leading' TO t-title. MOVE 'ssalut tout le monde' TO t-exp. MOVE ws-0 TO t-got. PERFORM test-section. INSPECT ws-0 REPLACING ALL 'o' by 'O' 't' by 'T'. MOVE 'inspect replacing all' TO t-title. MOVE 'ssaluT TOuT le mOnde' TO t-exp. MOVE ws-0 TO t-got. PERFORM test-section. INSPECT ws-0 REPLACING ALL 'T' by 't' BEFORE INITIAL SPACE. MOVE 'inspect replacing all before' TO t-title. MOVE 'ssalut TOuT le mOnde' TO t-exp. MOVE ws-0 TO t-got. PERFORM test-section. INSPECT ws-0 CONVERTING "sau" TO "SAU". MOVE 'inspect converting' TO t-title. MOVE 'SSAlUt TOUT le mOnde' TO t-exp. MOVE ws-0 TO t-got. PERFORM test-section. * ------------------------------------------------------------ STRING ws-0 DELIMITED BY SIZE ws-1 DELIMITED BY SIZE INTO ws-2. MOVE 'string' TO t-title. MOVE 'SSAlUt TOUT le mOnde Aurevoir' TO t-exp. MOVE ws-2 TO t-got. PERFORM test-section. * ------------------------------------------------------------ UNSTRING ws-2 DELIMITED BY ALL SPACES INTO ws-words1 ws-words2 ws-words3 ws-words4 ws-words5 MOVE 'unstring' TO t-title. MOVE 'SSAlUtTOUTlemOndeAurevoir' TO t-exp. MOVE ws-words TO t-got. PERFORM test-section. * ------------------------------------------------------------ PERFORM stop-run-section. * ============================================================ test-section. DISPLAY "----- TEST: " t-title " -----". IF t-exp = t-got THEN DISPLAY '[OK]' ELSE DISPLAY '[FAILURE]' DISPLAY 'Expected: ' t-exp DISPLAY 'Got: ' t-got END-IF ADD 1 TO t-count. INITIALIZE ws-count. EXIT. stop-run-section. STOP RUN.