17 August 2018 11:16:36 PM ISBN_TEST C++ version Test the ISBN library. CH_IS_DIGIT_TEST CH_IS_DIGIT is TRUE if a character represents a digit. C CH_IS_DIGIT(C) 0 '0' 1 1 '1' 1 2 '2' 1 3 '3' 1 4 '4' 1 5 '5' 1 6 '6' 1 7 '7' 1 8 '8' 1 9 '9' 1 10 'X' 0 11 '?' 0 12 ' ' 0 CH_IS_ISBN_DIGIT_TEST CH_IS_ISBN_DIGIT is TRUE if a character represents an ISBN digit. C CH_IS_ISBN_DIGIT(C) '0' 1 '1' 1 '2' 1 '3' 1 '4' 1 '5' 1 '6' 1 '7' 1 '8' 1 '9' 1 'X' 1 'x' 1 'Y' 0 '*' 0 '?' 0 ' ' 0 CH_TO_DIGIT_TEST CH_TO_DIGIT: character -> decimal digit 0 0 0 1 1 1 2 2 2 3 3 3 4 4 4 5 5 5 6 6 6 7 7 7 8 8 8 9 9 9 10 X -1 11 ? -1 12 -1 I4_TO_ISBN_DIGIT_TEST I4_TO_ISBN_DIGIT converts digits 0 to 10 to an ISBN digit. 0 '0' 1 '1' 2 '2' 3 '3' 4 '4' 5 '5' 6 '6' 7 '7' 8 '8' 9 '9' 10 'X' ISBN_CHECK_DIGIT_CALCULATE_TEST ISBN_CHECK_DIGIT_CALCULATE calculates the 10-th digit (the check digit) of a 10-digit ISBN. Check digit of '0-306-40615-2 is '2', expecting '2' Check digit of '0 8493 9640 is '9', expecting '9' Check digit of '158488059 is '7', expecting '7' Check digit of '246897531 is '6', expecting '6' Check digit of '135798642 is '4', expecting '4' ISBN_DIGIT_TO_I4_TEST ISBN_DIGIT_TO_I4 converts an ISBN digit to an I4 '0' 0 '1' 1 '2' 2 '3' 3 '4' 4 '5' 5 '6' 6 '7' 7 '8' 8 '9' 9 'X' 10 'x' 10 'Y' -1 '*' -1 '?' -1 ' ' -1 ISBN_IS_VALID_TEST ISBN_IS_VALID reports whether a ISBN is valid. Validity of '0-306-40615-2' is true, expecting true Validity of '0-326-40615-2' is false, expecting false Validity of '0 8493 9640 9' is true, expecting true Validity of '0 8493 9640 3' is false, expecting false Validity of '0-3870-9654-X' is true, expecting true Validity of '0-201-38597-x' is true, expecting true S_TO_DIGITS_TEST S_TO_DIGITS: string -> digit vector Test string: '34E94-70.6' Extracted 5 digits: 1 3 2 4 3 9 4 4 5 7 Test string: '34E94-70.6' Extracted 7 digits: 1 3 2 4 3 9 4 4 5 7 6 0 7 6 S_TO_ISBN_DIGITS_TEST S_TO_ISBN_DIGITS: string -> ISBN digit vector Test string: '34E9X-70.6' Extracted 5 digits: 1 3 2 4 3 9 4 10 5 7 Test string: '34E9X-70.6' Extracted 7 digits: 1 3 2 4 3 9 4 10 5 7 6 0 7 6 ISBN_TEST Normal end of execution. 17 August 2018 11:16:36 PM