#49 Add unittest for shellmatte_utils_removeChars

병합
sebastian shimatta/#48_Add_unittest_for_shellmatte_utils_removeChars 에서 shimatta/develop 로 6 commits 를 머지했습니다 4 년 전
sebastian 코멘트됨, 5 년 전

Finally comming back to this - everything seems to build fine on my end, also i can not identify any problem with the identation.

Finally comming back to this - everything seems to build fine on my end, also i can not identify any problem with the identation.
shimatta 코멘트됨, 5 년 전
소유자

Thanks for collaborating :) Testcases look nice!

Maybe there are two more testcases I can imagine (although the coverage is already at 100%):

  1. removing some chars in the middle of the buffer (without backspace)
  2. removing more chars in the middle of the buffer than there are (without backspace)

If you want to spend more time in this maybe some nonsense values can be tested (cursor outside of buffer size etc.). I guess this will break somehow ;)... ...maybe you should test the data in the write function as well with some assertions. The remove_chars method writes the changed line back to the terminal depending on the echo setting in the instance. This can be a pain in the ass to test but might be a valuable test as well.

Just some suggestions. Personally I would have ended up with quite the same testcases ;)

But there is one more serious problem with the makefile indentation ;) ...does this still run on your machine? on my system I get a "*** missing separator. Stop." error As far as I know make needs the tab character as indentation in targets. Would be nice if you revert this change ;)

But the rest is a good start. Thanks :)

Thanks for collaborating :) Testcases look nice! Maybe there are two more testcases I can imagine (although the coverage is already at 100%): 1. removing some chars in the middle of the buffer (without backspace) 2. removing more chars in the middle of the buffer than there are (without backspace) If you want to spend more time in this maybe some nonsense values can be tested (cursor outside of buffer size etc.). I guess this will break somehow ;)... ...maybe you should test the data in the write function as well with some assertions. The remove_chars method writes the changed line back to the terminal depending on the echo setting in the instance. This can be a pain in the ass to test but might be a valuable test as well. Just some suggestions. Personally I would have ended up with quite the same testcases ;) But there is one more serious problem with the makefile indentation ;) ...does this still run on your machine? on my system I get a "*** missing separator. Stop." error As far as I know make needs the tab character as indentation in targets. Would be nice if you revert this change ;) But the rest is a good start. Thanks :)
sebastian 코멘트됨, 5 년 전
협업자

Needs more Work for testing the data in the write function.

Currently the unittest fails in the folowing Cases: shellmatta_utils_removeChars_remove_chars_in_the_middle_of_the_buffer_backspace_false shellmatta_utils_removeChars_remove_more_chars_in_middle_of_buffer_than_are_present_backspace_false shellmatta_utils_removeChars_curser_outside_buffer

I Would like to suggest a change in utils_removeChars as follows:

if((0u != length) && (true == backspace))
{
    /** -# rewind the cursor in case of backspace */
        length = SHELLMATTA_MIN (length, inst->cursor);
        utils_rewindCursor(inst, length);

    /** -# delete the char at the cursor position */
    [...]

I do not think there is any benefit in writing a unchanged string back to console anyway :).

Hopefully the indentation issue is fixed now as well - sorry for that!

Needs more Work for testing the data in the write function. Currently the unittest fails in the folowing Cases: shellmatta_utils_removeChars_remove_chars_in_the_middle_of_the_buffer_backspace_false shellmatta_utils_removeChars_remove_more_chars_in_middle_of_buffer_than_are_present_backspace_false shellmatta_utils_removeChars_curser_outside_buffer I Would like to suggest a change in utils_removeChars as follows: if((0u != length) && (true == backspace)) { /** -# rewind the cursor in case of backspace */ length = SHELLMATTA_MIN (length, inst->cursor); utils_rewindCursor(inst, length); /** -# delete the char at the cursor position */ [...] I do not think there is any benefit in writing a unchanged string back to console anyway :). Hopefully the indentation issue is fixed now as well - sorry for that!
shimatta 코멘트됨, 5 년 전
소유자

Maybe it was not clear enough what the function utils_removeChars shall do with backspace == false.

I tried to improve the documentation to make this clear. Without backspace the function removes chars from the right hand side of the cursor, with backspace from the left hand side.

Due to the used VT100 like protocol it is not that easy to achive this :( - at least I do not know a better way than the implemented one:

  1. move the cursor to the left (if backspace == true)
  2. delete everything right of the cursor
  3. print everything right of the cursor again.

Maybe this seems a bit overkill in the typical use case (delete one char with backspace) - so far I did not come across a better way. As far as I know there is no sequence for deleting chars - you have to clear the whole line or overwrite the chars.

I changed the implementation a bit to get more robust on invalid cursors. Please take a look at it. It should prevent invalid shifting of the buffer content.

Maybe it was not clear enough what the function utils_removeChars shall do with backspace == false. I tried to improve the documentation to make this clear. Without backspace the function removes chars from the right hand side of the cursor, with backspace from the left hand side. Due to the used VT100 like protocol it is not that easy to achive this :( - at least I do not know a better way than the implemented one: 1. move the cursor to the left (if backspace == true) 2. delete everything right of the cursor 3. print everything right of the cursor again. Maybe this seems a bit overkill in the typical use case (delete one char with backspace) - so far I did not come across a better way. As far as I know there is no sequence for deleting chars - you have to clear the whole line or overwrite the chars. I changed the implementation a bit to get more robust on invalid cursors. Please take a look at it. It should prevent invalid shifting of the buffer content.
이 풀리퀘스트가 성공적으로 머지되었습니다!
로그인하여 이 대화에 참여
레이블 없음
마일스톤 없음
담당자 없음
참여자 2명
로딩중...
취소
저장
아직 콘텐츠가 없습니다.